class ManagedComponent

Inherits: Component

Component that internally wraps a Mono component object that can be of user-defined type.

Acts as interop layer between native Component and a Mono user defined component type since managed types cannot simply derive from Component to implement its functionality.

Public

Methods

~ManagedComponent

~ManagedComponent() noexcept = default

GetManagedInstance

MonoObject *GetManagedInstance() const

Returns managed component object instance.

GetClass

MonoClass *GetClass() const

Returns managed class of the component.

GetRuntimeType

MonoReflectionType *GetRuntimeType() const

Returns managed type of the component.

GetManagedNamespace

const String &GetManagedNamespace() const

Returns namespace of the managed component.

GetManagedTypeName

const String &GetManagedTypeName() const

Returns type name of the managed component.

GetManagedFullTypeName

const String &GetManagedFullTypeName() const

Returns namespace and type name of the component in format "namespace.typename".

Backup

RawBackupData Backup(bool clearExisting = true)

Serializes the internal managed component.

clearExisting
Should the managed component handle be released. (Will trigger a finalizer if this is the last reference to it)

Returns: An object containing the serialized component. You can provide this to restore() method to re-create the original component.

Restore

void Restore(const RawBackupData &data)

Restores a component from previously serialized data.

data
Serialized managed component data that will be used for initializing the new managed instance.

TriggerOnReset

void TriggerOnReset()

Triggers the managed OnReset callback.

Update

void Update() override

Called once per frame.

Only called if the component is in Running state.

TypeEquals

bool TypeEquals(const Component &other) override

Checks if this and the provided component represent the same type.

CalculateBounds

bool CalculateBounds(Bounds &bounds) override

Calculates bounds of the visible contents represented by this component (for example a mesh for Renderable).

bounds
Bounds of the contents in world space coordinates.

Returns: True if the component has bounds with non-zero volume, otherwise false.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Protected

Constructors

ManagedComponent

ManagedComponent(const HSceneObject &parent, MonoReflectionType *runtimeType)

ManagedComponent

ManagedComponent() = default

Methods

Initialize

void Initialize() override

Construct any resources the component needs before use.

Called when the parent scene object is initialized. A non-initialized component shouldn't be used in a live scene (i.e. it should not receive any of the component logic updates or events).

OnCreated

void OnCreated() override

Called once when the component has been created.

Called regardless of the state the component is in.

OnBeginPlay

void OnBeginPlay() override

Called once when the component first leaves the Stopped state.

This includes component creation if requirements for leaving Stopped state are met, in which case it is called after OnCreated. Note this is called even if the component is in disabled state.

OnDestroyed

void OnDestroyed() override

Called once just before the component is destroyed.

Called regardless of the state the component is in.

OnEnabled

void OnEnabled() override

Called every time a component leaves the Stopped state, if the component is enabled.

This includes component creation if requirements for leaving the Stopped state are met. When called during creation it is called after OnBeginPlay.

OnDisabled

void OnDisabled() override

Called every time a component is placed into the Stopped state.

This includes component destruction if component wasn't already in Stopped state during destruction. When called during destruction it is called before OnDestroyed.

OnTransformChanged

void OnTransformChanged(TransformChangedFlags flags) override

Called when the component's parent scene object has changed.

Not called if the component is in Stopped state. Also only called if necessary notify flags are set via SetNotifyFlagsInternal().

Private

Methods

SetupScriptBindings

void SetupScriptBindings(const SPtr<ManagedObjectInfo> &objectInformation)

Sets up script bindings between native and managed class.

Must be called after creating the script object wrapper, or after assembly is reloaded.

CreateScriptObject

MonoObject *CreateScriptObject(SPtr<ManagedObjectInfo> &outObjectInformation) const

Creates the script object of the correct type.

outObjectInformation
Information about the component type. Can be null in case the type does no longer exist.

Returns: Creates script object of the correct component type, or if type cannot be found, script object of missing type.

Fields

mManagedClass

MonoClass * mManagedClass

mRuntimeType

MonoReflectionType * mRuntimeType

mNamespace

String mNamespace

mTypeName

String mTypeName

mFullTypeName

String mFullTypeName

mRequiresReset

bool mRequiresReset

mMissingType

bool mMissingType

mSerializedObjectData

SPtr<ManagedSerializableObject> mSerializedObjectData

mObjInfo

SPtr<ManagedObjectInfo> mObjInfo

mOnCreatedThunk

OnCreatedThunkDef mOnCreatedThunk

mOnInitializedThunk

OnInitializedThunkDef mOnInitializedThunk

mOnUpdateThunk

OnUpdateThunkDef mOnUpdateThunk

mOnResetThunk

OnResetThunkDef mOnResetThunk

mOnDestroyThunk

OnDestroyedThunkDef mOnDestroyThunk

mOnDisabledThunk

OnDisabledThunkDef mOnDisabledThunk

mOnEnabledThunk

OnEnabledThunkDef mOnEnabledThunk

mOnTransformChangedThunk

OnTransformChangedThunkDef mOnTransformChangedThunk

mCalculateBoundsMethod

MonoMethod * mCalculateBoundsMethod