Skip to content

Transform Component ​

位置・回転・拡縮と親子関係を保持します。すべての通常GameObjectに付いています。

設定する手順 ​

  1. HierarchyでGameObjectを選び、Inspectorの移動・回転・拡縮を変更します。
  2. SceneViewまたはGameViewで結果を確認します。
  3. 編集中のSceneまたはPrefabを保存します。

項目の説明 ​

複雑な設定は下記の専用APIとInspectorの編集欄を使用します。

Inspectorの設定と使い方 ​

「Editor / C#」は両方から変更できる設定、「Editorのみ」は公開C# APIのない編集操作です。「Editor表示のみ」は計算結果や統計などの確認欄です。「C#のみ」は、このInspectorに編集欄のない操作です。

設定・操作編集場所C#の入口意味・使い方
次元Editorのみ—2D向けか3D向けかを指定します。Inspectorの表示軸や関連処理の基準になります。現在のTransformのC# APIに次元を直接変更するプロパティはありません。
位置・回転・スケールEditor / C#localPosition / localEulerAngles / localScaleInspectorでは親を基準にした値を編集します。位置のWorld値はposition、回転のWorld値はrotationです。eulerAngles系は度数、rotation系はQuaternionを使います。
親の回転・スケールを無視Editor / C#ignoreParentRotation / ignoreParentScale親へ追従しながら、指定した成分の継承だけを外します。UIや頭上表示など、親の拡縮をそのまま受けたくない配置に使います。
ワールド行列Editor表示のみ—親子階層を含めた最終的な変換結果です。直接編集せず、Transformの値や親子付けを変更します。
親子付けと座標変換C#のみSetParent / TransformPoint / InverseTransformPointSetParentのworldPositionStaysでWorld位置を保つかを指定します。ローカルの発射位置をWorldへ変換する場合はTransformPointを使います。

初期値はEngineのComponent定義時の値で、C++表記を含みます。C#へ貼り付ける実行例ではありません。既存Sceneの保存値や既定Assetがある場合はそちらが優先されます。数値の編集範囲はInspectorで制限される場合があります。

C#から使う ​

操作型はTransformです。 GameObjectから取得する基本操作はGameObjectの操作を参照してください。以下には基本プロパティだけでなく、公開関数・追加の設定API・継承した共通操作も掲載します。

実用例:入力で物体を移動する ​

このGameObjectへ追加し、Play中に左右キーで移動します。物理のDynamic Bodyを直接動かす例ではありません。

cs
using NEMEngine;

public sealed class FirstMover : MonoBehaviour {

    [SerializeField] private float speed = 2.0f;

    void Update() {
        // 左右キーから移動方向を作る
        float horizontal = 0.0f;
        if (Input.GetKey(KeyCode.LeftArrow)) horizontal -= 1.0f;
        if (Input.GetKey(KeyCode.RightArrow)) horizontal += 1.0f;
        // 経過秒を掛けてWorld座標で移動
        transform.Translate(new Vector3(horizontal, 0.0f, 0.0f) * speed * Time.deltaTime, Space.World);
    }
}

設定用・関連するC#型 ​

選択値(Enum) ​

型・各値の詳説使える値
SpaceSelf / World

Transform ​

宣言・詳説種類・操作役割
public static Transform FromEntity(GameObject gameObject)関数既にComponentを持つGameObjectから操作用の参照を作ります。Componentを追加する操作ではありません。
public Transform GetChild(int index)関数指定した子を取得し、範囲外は呼出し元へ返す
public Vector3 InverseTransformDirection(Vector3 direction)関数world direction をローカル空間へ戻す。
public Vector3 InverseTransformPoint(Vector3 point)関数world point をこの Transform のローカル空間へ戻す。
public void LookAt(Vector3 target)関数target を向く world 回転を設定する。target が現在位置とほぼ同じなら何もしない(ゼロ長 direction 対策)。
public void Rotate(Quaternion rotation, Space space = Self)関数クォータニオンで回転を加える。Unity と同じく Self は localRotationdelta、World は deltarotation。
public void Rotate(Vector3 eulerAngles, Space space = Self)関数オイラー角(度)で回転を加える。Space.Self はローカル回転へ後乗算、Space.World はワールド回転へ前乗算。
public void SetParent(Transform? parent, bool worldPositionStays = true)関数親の変更後もworld座標を保つか指定する
public void SetPositionAndRotation(Vector3 position, Quaternion rotation)関数world position と world rotation を一括設定する(個別 setter と同じ内部実装へ委譲)。
public Vector3 TransformDirection(Vector3 direction)関数direction を world 回転で写す(位置・scale の影響は受けない)。
public Vector3 TransformPoint(Vector3 point)関数position を world 空間の point として変換する(lossyScale → world 回転 → world 位置)。
public void Translate(Vector3 translation, Space space = Self)関数translation 分だけ移動する。Space.Self は自身の回転を掛けたローカル軸方向、Space.World はワールド軸方向。
public int childCountプロパティ(読取専用)子の数。firstChild / nextSibling を辿って数える(hierarchy は native 側が一貫管理)
public static int componentTypeIDプロパティ(読取専用)組み込みComponentの接続識別子です。通常のゲームコードではGetComponentで取得します。
public Vector3 eulerAnglesプロパティ(読取・変更)ワールド回転をZXYの角度で扱う
public Vector3 forwardプロパティ(読取専用)world 回転を基準にした各方向ベクトル
public bool ignoreParentRotationプロパティ(読取・変更)親(エンティティ階層 / スキンメッシュのジョイント)追従で回転を無視するか。座標は常に追従する
public bool ignoreParentScaleプロパティ(読取・変更)親追従でスケールを無視するか
public Vector3 localEulerAnglesプロパティ(読取・変更)ローカル回転をZXYの角度で扱う
public Vector3 localPositionプロパティ(読取・変更)親に対するローカル位置です。
public Quaternion localRotationプロパティ(読取・変更)親に対する回転Quaternionです。
public Vector3 localScaleプロパティ(読取・変更)親に対する拡縮倍率です。
public Vector3 lossyScaleプロパティ(読取専用)world(lossy) scale。親階層の継承設定を反映した成分積の近似値(読み取り専用)
public Transform? parentプロパティ(読取・変更)親TransformまたはPhaseの追従設定です。
public Vector3 positionプロパティ(読取・変更)ワールド空間の位置です。
public Vector3 rightプロパティ(読取専用)右方向の単位ベクトルです。
public Quaternion rotationプロパティ(読取・変更)world回転。親階層の継承設定を反映し、setも同じ親回転でlocalへ変換される
public Vector3 upプロパティ(読取専用)上方向の単位ベクトルです。

継承する共通操作:Component ​

宣言・詳説種類・操作役割
public T AddComponent<T>() where T : Component関数ComponentまたはScriptを追加し、操作する参照を返します。
public T? GetComponent<T>() where T : class関数component access(owner GameObjectへの委譲)
public T? GetComponentInChildren<T>(bool includeInactive = false) where T : class関数子階層から指定型のComponentを探します。
public T? GetComponentInParent<T>(bool includeInactive = false) where T : class関数親階層から指定型のComponentを探します。
public T[] GetComponents<T>() where T : class関数同じGameObjectにある指定型のComponentをすべて取得します。
public void GetComponents<T>(List<T> results) where T : class関数同じGameObjectにある指定型のComponentをすべて取得します。
public T[] GetComponentsInChildren<T>(bool includeInactive = false) where T : class関数子階層にある指定型のComponentを収集します。
public void GetComponentsInChildren<T>(bool includeInactive, List<T> results) where T : class関数子階層にある指定型のComponentを収集します。
public void GetComponentsInChildren<T>(List<T> results) where T : class関数子階層にある指定型のComponentを収集します。
public T[] GetComponentsInParent<T>(bool includeInactive = false) where T : class関数親階層にある指定型のComponentを収集します。
public void GetComponentsInParent<T>(bool includeInactive, List<T> results) where T : class関数親階層にある指定型のComponentを収集します。
public override int GetHashCode()関数同じ値を検索Keyに使うためのHashを返します。
public bool HasComponent<T>() where T : class関数指定型のComponentを持つかを調べます。
public void RemoveComponent<T>() where T : Component関数指定型のComponentを取り除きます。
public bool TryGetComponent<T>(out T component) where T : class関数Componentを検索し、見つかったかをbool、結果をout引数で返します。
public GameObject gameObjectプロパティ(読取専用)このComponentを所有するGameObjectです。
public Transform transformプロパティ(読取専用)所有GameObjectのTransformです。

継承する共通操作:Object ​

宣言・詳説種類・操作役割
public static void Destroy(Object? target)関数参照先の個体だけを安全地点で破棄する
public override bool Equals(object? obj)関数2つの値が等しいかを調べます。
public override int GetHashCode()関数同じ値を検索Keyに使うためのHashを返します。
public static GameObject Instantiate(Prefab original)関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static GameObject Instantiate(Prefab original, GameObject? parent)関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static GameObject Instantiate(Prefab original, Vector3 position, Quaternion rotation)関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static GameObject Instantiate(Prefab original, Vector3 position, Quaternion rotation, GameObject? parent)関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static T Instantiate<T>(T original) where T : Object関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static T Instantiate<T>(T original, GameObject? parent) where T : Object関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static T Instantiate<T>(T original, Vector3 position, Quaternion rotation) where T : Object関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static T Instantiate<T>(T original, Vector3 position, Quaternion rotation, GameObject? parent) where T : Object関数Prefabまたは指定したGameObject・Componentを複製して参照を返します。生成できない場合は例外です。nullを返す前提で処理しないでください。
public static bool operator ==(Object? lhs, Object? rhs)関数等値比較を行います。引数型と戻り値型で、成分ごとの演算か対象参照の比較かを確認してください。
public static implicit operator bool(Object? value)関数暗黙の型変換を行います。引数型と戻り値型で、成分ごとの演算か対象参照の比較かを確認してください。
public static bool operator !=(Object? lhs, Object? rhs)関数不等値比較を行います。引数型と戻り値型で、成分ごとの演算か対象参照の比較かを確認してください。

使用時の注意 ​

位置のワールド値とローカル値を区別します。親のScaleは子にも影響します。

Play中の変更は実行用Worldへ反映します。Scene編集のUndoと実行中の値の変更は別です。保存方法は編集と実行時変更を参照してください。

関連項目 ​

現行版マニュアル · 8ea58ba2 · 2026-10-28確認