Class Scripting
Embedded managed scripting runtime service.
Inheritance
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Scripting/Scripting.h
Syntax
public class Scripting
Fields
BinaryModuleLoaded
Action fired when scripting loads a binary module (eg. with game scripts).
Declaration
public static Delegate<BinaryModule* > BinaryModuleLoaded
Field Value
Delegate<BinaryModule >
|
Draw
Occurs on scripting draw update. Called during frame rendering and can be used to invoke custom rendering with GPUDevice.
Declaration
public static Delegate Draw
Field Value
Delegate
|
Exit
Occurs when scripting engine is disposing. Engine is during closing and some services may be unavailable (eg. loading scenes). This may be called after the engine fatal error event.
Declaration
public static Delegate Exit
Field Value
Delegate
|
FixedUpdate
Occurs on scripting fixed update.
Declaration
public static Delegate FixedUpdate
Field Value
Delegate
|
LateFixedUpdate
Occurs on scripting late fixed update.
Declaration
public static Delegate LateFixedUpdate
Field Value
Delegate
|
LateUpdate
ObjectsLookupIdMapping
The objects lookup identifier mapping used to override the object ids on FindObject call (used by the object references deserialization).
Declaration
public static ThreadLocal<IdsMappingTable* , PLATFORM_THREADS_LIMIT> ObjectsLookupIdMapping
Field Value
ThreadLocal<IdsMappingTable , PLATFORM_THREADS_LIMIT>
|
ScriptsLoaded
Action fired on scripting engine loaded (always main thread).
Declaration
public static Delegate ScriptsLoaded
Field Value
Delegate
|
ScriptsReloaded
Action fired on scripting engine reload start (always main thread).
Declaration
public static Delegate ScriptsReloaded
Field Value
Delegate
|
ScriptsReloading
Action fired on scripting engine reload start (always main thread).
Declaration
public static Delegate ScriptsReloading
Field Value
Delegate
|
ScriptsUnload
Action fired on scripting engine unloading start (always main thread).
Declaration
public static Delegate ScriptsUnload
Field Value
Delegate
|
Update
Methods
FindClass(const StringAnsiView& fullname)
Finds the class with given fully qualified name within whole assembly.
Declaration
public static MClass* FindClass(const StringAnsiView& fullname)
Parameters
StringAnsiView
fullname
The full name of the type eg: System.Int64. |
Returns
MClass
The MClass object or null if missing. |
FindObject(const Guid& id)
Finds the object by the given identifier. Searches registered scene objects and optionally assets. Logs warning if fails.
Declaration
public static T* FindObject(const Guid& id)
Parameters
Guid
id
The object unique identifier. |
Returns
T
The found object or null if missing. |
Type Parameters
typename T
|
FindObject(const MObject* managedInstance)
Finds the object by the given managed instance handle. Searches only registered scene objects.
Declaration
public static ScriptingObject* FindObject(const MObject* managedInstance)
Parameters
MObject
managedInstance
The managed instance pointer. |
Returns
ScriptingObject
The found object or null if missing. |
FindObject(Guid id, const MClass* type=nullptr)
Finds the object by the given identifier. Searches registered scene objects and optionally assets. Logs warning if fails.
Declaration
public static ScriptingObject* FindObject(Guid id, const MClass* type=nullptr)
Parameters
Guid
id
The object unique identifier. |
MClass
type
The type of the object to find (optional). |
Returns
ScriptingObject
The found object or null if missing. |
FindScriptingType(const StringAnsiView& fullname)
Finds the scripting type of the given fullname by searching loaded scripting assemblies.
Declaration
public static ScriptingTypeHandle FindScriptingType(const StringAnsiView& fullname)
Parameters
StringAnsiView
fullname
The full name of the type eg: System.Int64. |
Returns
ScriptingTypeHandle
The scripting type or invalid type if missing. |
GetObjects()
Gets all registered scripting objects.
Use with caution due to potentially large memory allocation.
Declaration
public static Array<ScriptingObject* , HeapAllocation> GetObjects()
Returns
Array<ScriptingObject , HeapAllocation>
The collection of the objects. |
GetRootDomain()
GetScriptsDomain()
Gets the scripts domain (it can be the root domain if not using separate domain for scripting).
Declaration
public static MDomain* GetScriptsDomain()
Returns
MDomain
|
HasGameModulesLoaded()
Returns true if game modules are loaded.
Declaration
public static bool HasGameModulesLoaded()
Returns
bool
|
IsEveryAssemblyLoaded()
Returns true if every assembly is loaded.
Declaration
public static bool IsEveryAssemblyLoaded()
Returns
bool
|
IsTypeFromGameScripts(const MClass* type)
Returns true if given type is from one of the game scripts assemblies.
Declaration
public static bool IsTypeFromGameScripts(const MClass* type)
Parameters
MClass
type
|
Returns
bool
|
Load()
Load/Reload scripts now
Declaration
public static bool Load()
Returns
bool
True if failed or cannot be done, otherwise false |
NewObject(const MClass* type)
Creates a new instance of the given class object (native construction).
Declaration
public static ScriptingObject* NewObject(const MClass* type)
Parameters
MClass
type
The Managed type class. |
Returns
ScriptingObject
The created object or null if failed. |
NewObject(const ScriptingTypeHandle& type)
Creates a new instance of the given type object (native construction).
Declaration
public static ScriptingObject* NewObject(const ScriptingTypeHandle& type)
Parameters
ScriptingTypeHandle
type
The scripting object type class. |
Returns
ScriptingObject
The created object or null if failed. |
OnManagedInstanceDeleted(ScriptingObject* obj)
Event called by the internal call on a finalizer thread when the managed objects gets deleted by the GC.
Declaration
public static void OnManagedInstanceDeleted(ScriptingObject* obj)
Parameters
ScriptingObject
obj
The unmanaged object pointer that was related to the managed object. |
ProcessBuildInfoPath(String& path, const String& projectFolderPath)
Declaration
public static void ProcessBuildInfoPath(String& path, const String& projectFolderPath)
Parameters
String
path
|
String
projectFolderPath
|
Release()
Release scripting layer (will destroy internal scripts data)
Declaration
public static void Release()
Reload(bool canTriggerSceneReload=true)
Reloads scripts.
Declaration
public static void Reload(bool canTriggerSceneReload=true)
Parameters
bool
canTriggerSceneReload
True if allow to scene scripts reload callback, otherwise it won't be possible. |
TryFindObject(const Guid& id)
Tries to find the object by the given identifier.
Declaration
public static T* TryFindObject(const Guid& id)
Parameters
Guid
id
The object unique identifier. |
Returns
T
The found object or null if missing. |
Type Parameters
typename T
|
TryFindObject(const MClass* type)
Tries to find the object by the given class.
Declaration
public static ScriptingObject* TryFindObject(const MClass* type)
Parameters
MClass
type
The type of the object to find. |
Returns
ScriptingObject
The found object or null if missing. |
TryFindObject(Guid id, const MClass* type=nullptr)
Tries to find the object by the given identifier.
Declaration
public static ScriptingObject* TryFindObject(Guid id, const MClass* type=nullptr)
Parameters
Guid
id
The object unique identifier. |
MClass
type
The type of the object to find (optional). |
Returns
ScriptingObject
The found object or null if missing. |