uLua v2.2.0
A Lua Modding Framework for Unity.
|
This script sets up the API framework to your Unity scene. More...
Public Member Functions | |
ScriptPackage | GetPackage (string PackageName) |
Returns the ScriptPackage object for the specified package name. If the package is not found, returns a null value. More... | |
int | GetPackageCount () |
Returns the number of packages found under the script package path. | |
string | GetPackageName (int i) |
Returns the name of the package at the specified index. | |
bool | LoadPackage (string PackageName) |
Public function used to load a ScriptPackage on demand. More... | |
Static Public Member Functions | |
static bool | ExecuteExternalFile (string File, bool overwriteExisting=false) |
Executes a script from the external directory. More... | |
static bool | ExecuteFile (string File, bool overwriteExisting=false) |
Executes a script from the resource directory. More... | |
static void | Expose< T > (T Object, LuaMonoBehaviour Context=null) |
Exposes an object to Lua. More... | |
static void | Invoke (string Event, params object[] args) |
Invokes a game event. More... | |
static void | Log (string String) |
Logs a message to the console. More... | |
static void | LogError (string String) |
Logs an error to the console. More... | |
static void | LogWarning (string String) |
Logs a warning to the console. More... | |
static void | LoadSavedData (LuaMonoBehaviour Object, string Index="SaveData") |
Loads table data saved for the specified object. More... | |
static void | RegisterEvent (string Event, string HandlerName="") |
Registers an event to the API. More... | |
static bool | RegisterEventHandler (string Event, string HandlerName, ILuaObject Context=null) |
Registers an event handler to be called when an event is invoked. More... | |
static void | RemoveEventHandlers (LuaMonoBehaviour Context) |
Removes all event handlers registered in a specific context. More... | |
static void | RegisterIndexedType (Type Type) |
Registers a type that implements the ILuaObject interface to Lua. More... | |
static void | RegisterType< T > () |
Registers a type to Lua. More... | |
static void | SaveData (LuaMonoBehaviour Object, string Index="SaveData") |
Saves table data from the specified object. More... | |
static bool | TryRegisterEventHandler (string HandlerName, ILuaObject Context=null) |
Attempts to register an event handler for a registered event. More... | |
Static Public Attributes | |
static string | ExternalDirectory = "" |
Directory for external Lua scripts. The path is determined at run-time. | |
static string | SaveDataPath = "" |
Path for user save data under the external directory. | |
static string | ScriptsPath = "" |
Path for user scripts under the external directory. | |
static string | MainResourcesFolder = "" |
Path to the main resources folder for scripts. Used by the VS Code debugger to find the Lua scripts. | |
static string | ScriptPackagesPath = "" |
Path for script packages under the external directory. | |
static string | LuaScriptsExtension = "" |
File extension for all external Lua scripts. | |
This script sets up the API framework to your Unity scene.
Includes methods to execute Lua scripts, expose game objects to the API, and invoke events. Inherits from MonoBehaviour. Intended use is to add to an object in the scene and set up for use.
This script invokes the SceneLoaded
event when the scene is loaded.
|
inlinestatic |
Executes a script from the external directory.
File | The Lua file to execute. The file extension must be omitted. |
overwriteExisting | (Optional) If true, the method will overwrite any previous script with the same filename. Otherwise, any previous script will be called from a hash table. |
|
inlinestatic |
Executes a script from the resource directory.
File | The Lua file to execute. The file extension must be omitted. |
overwriteExisting | (Optional) If true, the method will overwrite any previous script with the same filename. Otherwise, any previous script will be called from a hash table. |
|
inlinestatic |
Exposes an object to Lua.
Called internally by uLua.ExposedMonoBehaviour.Start(). Can be called manually at an earlier point or for objects which have ExposeOnStart
disabled.
Object | The object to be exposed to Lua. The generic type T must implement the ILuaObject interface. |
Context | The Lua context of the object. If null, the object will be exposed as a global. |
T | : | class | |
T | : | ILuaObject |
|
inline |
Returns the ScriptPackage object for the specified package name. If the package is not found, returns a null value.
PackageName | The name of the package. |
|
inlinestatic |
Invokes a game event.
This method is exposed to Lua as a global and may be called from a Lua script or within C#. Events should registered AFTER Unity's Awake call to prevent unexpected behaviour (e.g. on Unity's scene loaded or start events). Events may also be registered when an object is exposed to Lua by overriding uLua.ExposedMonoBehaviour.OnExpose().
Event | The name of the event to be invoked. |
args | (Optional) Parameters for the event handler. |
|
inline |
Public function used to load a ScriptPackage on demand.
PackageName | The name of the ScriptPackage to be loaded. |
|
inlinestatic |
Loads table data saved for the specified object.
Saved data will be loaded from the SaveDataPath
under the external directory. This method is exposed to Lua as a global and may be called from a Lua script or within C#.
Object | The object of which the saved data will be loaded. |
Index | (Optional) The index of Object which contains the table data to be saved. Default value is "SaveData". |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Registers an event to the API.
Events should registered AFTER Unity's Awake call to prevent unexpected behaviour (e.g. on Unity's scene loaded or start events). Events may also be registered when an object is exposed to Lua by overriding uLua.ExposedMonoBehaviour.OnExpose().
Event | The name of the event to be registered. |
HandlerName | (Optional) The name of the event handler function. Defaults to 'On{Event}', e.g. the default even thandler for an event named 'LoadingFinished' would be 'OnLoadingFinished', |
|
inlinestatic |
Registers an event handler to be called when an event is invoked.
This method is exposed to Lua as a global and may be called from a Lua script or within C#.
Event | The name of the event. |
HandlerName | The name of the event handler function. |
Context | (Optional) The object that contains the event handler implementation. If not specified, the event handler will be global. |
|
inlinestatic |
Registers a type that implements the ILuaObject interface to Lua.
Intended for use with LuaMonoBehaviour and LuaClass.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Saves table data from the specified object.
Data will be saved to the SaveDataPath
under the external directory. This method is exposed to Lua as a global and may be called from a Lua script or within C#.
Object | The object for which the data will be saved. |
Index | (Optional) The index of Object which contains the table data to be saved. Default value is "SaveData". |
|
inlinestatic |
Attempts to register an event handler for a registered event.
HandlerName | The name of the event handler function. If a matching registered event is not found, this function has no effect. |
(Optional) | Context The object that contains the event handler implementation. If not specified, the event handler will be global. |