// this will be a "Transform" field in Unity
@serializable(Object3D)
myObjectReference: Object3D | null = null;
https://engine.needle.tools/docs/scripting.html#serialization-components-in-gltf-files
// this will be a "Transform" field in Unity
@serializable(Object3D)
myObjectReference: Object3D | null = null;
https://engine.needle.tools/docs/scripting.html#serialization-components-in-gltf-files
If you want this to be a Transform you can annotate it with a comment like so:
//@type UnityEngine.Transform
@serializable(Object3D)
myTransform?: Object3D;
At runtime it will both be a Object3D
Also note that your second example is missing the Object3D in the @serializable: @serializable(Object3D)
is required so that it results in the correct type. A GameObject and a Object3D are essentially the same - the GameObject type just exposes some more methods
How About Enum Show this in Unity
enum Direction {
Up = 1,
Down = 5,
Left = 10,
Right = 15
}
export class GameManager extends Behaviour {
dir: Direction = Direction.Left;
}
You can just declare it like this in your Needle component:
enum Direction = {
Up = 1,
Down = 5,
Left = 10,
Right = 15,
}
export class GameManager extends Behaviour {
@serializable()
dir: Direction = Direction.Left;
}
and in Unity make sure you have an enum with the name Direction in your C# code somewhere. Then it will be show up as an enum dropdown (we donβt automatically generate new C# enum types so you need to make sure that this type exists in Unity and it will be picked up by our compiler the next time it runs)
This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.