Interface ILunyObject
See implementation: LunyObject
public interface ILunyObject
Expand Details ...
Properties
IsEnabled
Whether the engine object is processing and visible. Matches the "Active" state of Unity.
Boolean IsEnabled { get; set; }
Property Value
- Boolean
Remarks
The object may be enabled, but still be disabled in the hierarchy due to a parent not being enabled. IsEnabled also toggles visibility. If the object's IsVisible was set to false, and then the object gets enabled, the object's IsVisible state will also change to true.
IsEnabledInHierarchy
Returns true only if BOTH the object itself AND all of its parents are enabled. Otherwise returns false.
Boolean IsEnabledInHierarchy { get; }
Property Value
- Boolean
IsNativeObjectValid
Is true when Destroy() was called on the NativeObject and it was set to null.
Boolean IsNativeObjectValid { get; }
Property Value
- Boolean
IsValid
Whether the object and its native representation are valid (not null, not destroyed).
Boolean IsValid { get; }
Property Value
- Boolean
IsVisible
Whether the object is visible (will render).
Boolean IsVisible { get; set; }
Property Value
- Boolean
Remarks
This property does NOT imply that the object is currently visible on screen. It is technically visible, but may still be outside the camera's frame, obstructed by other objects, fully transparent, scaled infinitely small, etc.
LunyObjectId
Unique, immutable identifier for LunyObject. This ID is distinct from engine's native object ID!
LunyObjectId LunyObjectId { get; }
Property Value
Name
The name of the object in the scene hierarchy.
String Name { get; set; }
Property Value
- String
Remarks
To aid debugging, this property remains valid even after the object has been destroyed.
NativeObject
Gets the underlying engine-native object (GameObject, Node) as generic System.Object type. Use the Cast<T>() or As<T>() methods to avoid manually casting the reference.
Object NativeObject { get; }
Property Value
- Object
NativeObjectId
Engine-native object's unique, immutable identifier. Subject to engine's behaviour (ie may change between runs).
LunyNativeObjectId NativeObjectId { get; }
Property Value
Remarks
To aid debugging, this ID remains valid after the engine-native object has been destroyed.
Transform
The LunyTransform of this object.
LunyTransform Transform { get; }
Property Value
Methods
As<T>()
Gets the engine-native object as type T. Returns null for non-matching types.
T As<T>() where T : class
Returns
- T
Type Parameters
T
Cast<T>()
Gets the engine-native object cast to T. Throws if the type cast is invalid.
T Cast<T>() where T : class
Returns
- T
Type Parameters
T
Clone()
Creates a new instance of the current object.
ILunyObject Clone()
Returns
Clone(LunyTransform)
Creates a new instance of the current object and parents it.
ILunyObject Clone(LunyTransform parent)
Parameters
| Type | Name | Description |
|---|---|---|
parent |
Returns
Destroy()
Marks this object for destruction. If object is enabled, will run its OnDisabled event. Then it run its OnDestroyed event.
void Destroy()
Remarks
The engine-native object destruction is deferred until the end of the current frame to prevent exceptions.
Events
OnCollisionEntered
Runs when the object's collider has "entered" (overlaps) another static or non-kinematic collider.
event Action<LunyCollision> OnCollisionEntered
Event Type
OnCollisionEntered2D
event Action<LunyCollision2D> OnCollisionEntered2D
Event Type
OnCollisionExited
Runs when the object's collider stops overlapping/touching another static or non-kinematic collider.
event Action<LunyCollision> OnCollisionExited
Event Type
OnCollisionExited2D
event Action<LunyCollision2D> OnCollisionExited2D
Event Type
OnCollisionUpdate
Runs every heartbeat while the collision is ongoing.
event Action<LunyCollision> OnCollisionUpdate
Event Type
OnCollisionUpdate2D
event Action<LunyCollision2D> OnCollisionUpdate2D
Event Type
OnCreated
Runs when the object was created or ownership was transferred to LunyEngine. Runs even if the object starts disabled.
event Action OnCreated
Event Type
Remarks
Engine-native creation events (Unity: Awake, OnEnable / Godot: ctor, _init) will run before OnCreated. OnEnabled will run right after OnCreated if the object starts enabled.
OnDestroyed
Runs when the object was destroyed. Runs even if the object is disabled.
event Action OnDestroyed
Event Type
Remarks
The object's NativeObject reference is still accessible, it has not been destroyed yet.
OnDisabled
Runs when the object's enabled state changes to "disabled": hidden, not updating, not receiving events, not interacting with other objects.
event Action OnDisabled
Event Type
OnEnabled
Runs when the object's enabled state changes to "enabled": visible, updating, receiving events, interacting with other objects. Also runs right after OnCreated if the object starts enabled.
event Action OnEnabled
Event Type
OnReady
Runs once before the object's first frame processing, before OnFrameUpdate and OnHeartbeat. If the object starts disabled, OnReady runs after the object first gets enabled.
event Action OnReady
Event Type
Remarks
It is not guaranteed that the object will simulate physics in its first active frame. The event order is either: OnReady => OnFrameUpdate (object's first) or: OnReady => OnHeartbeat (object's first) => OnFrameUpdate (object's first)
OnTriggerEntered
Runs when first overlapping a trigger collider.
event Action<LunyCollider> OnTriggerEntered
Event Type
OnTriggerEntered2D
event Action<LunyCollider2D> OnTriggerEntered2D
Event Type
OnTriggerExited
Runs when leaving a trigger collider.
event Action<LunyCollider> OnTriggerExited
Event Type
OnTriggerExited2D
event Action<LunyCollider2D> OnTriggerExited2D
Event Type
OnTriggerUpdate
Runs while overlapping a trigger collider.
event Action<LunyCollider> OnTriggerUpdate
Event Type
Remarks
In Unity, to receive this event you have to explicitly enable it: Project Settings: Physics/Settings -> GameObject -> Generate On Trigger Stay Events
OnTriggerUpdate2D
event Action<LunyCollider2D> OnTriggerUpdate2D