public readonly ref struct TransformThe user-facing view of an entity's transform: reads the world matrix, writes the local one.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
A ref struct holding a world and an entity and nothing else, so it costs nothing to make and cannot outlive the frame it was made in — which is the point. It is a view, not a component: every read goes to the chunk and every write goes to the chunk, so two façades over the same entity can never disagree.
Setting a world-space property writes the local one with the parent's inverse applied, the same semantics Unity has. It uses the parent's WorldTransform as it stands now, which is what the last TransformSystem pass produced — so a child moved in the same frame as its parent lands where the parent was at the start of the frame, and is corrected by the next pass. That is Unity's behaviour too, and it is the reason hierarchy-sensitive code belongs in SystemPhase.LateUpdate.
Fields and properties (12)
public Entity EntityThe entity being viewed.
public Vector3 LocalPositionPosition relative to the parent.
public Quaternion LocalRotationRotation relative to the parent.
public Vector3 LocalScaleScale relative to the parent.
public Matrix4x4 LocalToWorldThe local-to-world matrix, as of the last transform pass.
public Vector3 PositionPosition in world space.
public Quaternion RotationRotation in world space.
public Vector3 LossyScaleScale in world space, which is a lie whenever a parent's rotation and scale disagree — hence the name, and hence there being no setter.
public Vector3 ForwardThe direction the entity faces: its local -Z, in world space.
public Vector3 RightThe entity's local +X, in world space.
public Vector3 UpThe entity's local +Y, in world space.
public Entity ParentThe entity's parent, or Null.
Methods (8)
public Transform(World world, Entity entity)Views an entity's transform.
public Vector3 TransformPoint(Vector3 point)Takes a point from this entity's space into world space.
public Vector3 TransformDirection(Vector3 direction)Takes a direction from this entity's space into world space, ignoring translation.
public Vector3 InverseTransformPoint(Vector3 point)Takes a point from world space into this entity's space.
public void LookAt(Vector3 target, Vector3 up = default(Vector3))Turns the entity to face a world-space point.
public void Translate(Vector3 offset)Moves the entity by a world-space offset.
public override string ToString()Renders the entity and its world position.
public static Quaternion LookRotation(Vector3 forward, Vector3 up)The rotation that takes local -Z onto a direction, with a chosen up.
Used by (13)
- BehaviorVixen.Engine
- ControlRotationVixen.Engine
- TransformSystemTestsVixen.Engine.Tests
- VirtualCameraSystemVixen.Engine
- ComponentGizmosVixen.Editor.SceneView
- EditorApplicationVixen.Editor.App
- EntityGizmoTargetVixen.Editor.SceneView
- GizmoPlacementVixen.Editor.SceneView
- MeshEditTestsVixen.Editor.SceneView.Tests
- OutlinerColumnTestsVixen.Editor.App.Tests
- ScenarioTestsVixen.Editor.App.Tests
- SceneEntityVixen.Editor.App
- SceneLinesVixen.Editor.SceneView