Instance Transform

Represents an instance’s position, rotation, and scale

FloraInstanceTransform is a lightweight struct used to represent an instance’s position, rotation, and scale—either relative to a parent (local space) or in world space when no parent is assigned.

Its design and API are based on Unity’s LocalTransform from the Entities package.


Usage

Defining an Instance Transform

Instances can be placed using local-space transform data relative to a parent Transform:

var localTransform = new FloraInstanceTransform(localPosition, localRotation, localScale);
FloraSystem.Instance.CreateInstance(prefab, this.transform, localTransform);

Converting from a Unity Transform

You can construct a FloraInstanceTransform from a Transform, in either local or world space:

var local = FloraInstanceTransform.FromUnityTransform(this.transform, Space.Self);
var world = FloraInstanceTransform.FromUnityTransform(this.transform, Space.World);

Writing Instance Transforms

To update an instance’s transform after creation:

FloraSystem.Instance.UpdateInstanceWorldTransform(handle, transform);

You can also update multiple instances at once using arrays or native containers.

Transform Composition and Manipulation

FloraInstanceTransform includes utility methods for manipulating transform data:

transform = transform.RotateY(math.radians(90)).Translate(new float3(0, 1, 0));

Last updated