uLua v2.2.0
A Lua Modding Framework for Unity.
uLua.ScriptLoader Class Reference

A script loader to load scripts from assets in Unity from within the Lua context. Scripts will be loaded from a subdirectory of Assets/Resources. More...

Public Member Functions

 ScriptLoader (string AssetsPath)
 Initializes a new instance of the uLua.ScriptLoader class. More...
 
override object LoadFile (string file, Table globalContext)
 Opens a file for reading the script code. It can return either a string, a byte[] or a Stream. If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. More...
 
override bool ScriptFileExists (string file)
 Checks if a given file exists. More...
 

Detailed Description

A script loader to load scripts from assets in Unity from within the Lua context. Scripts will be loaded from a subdirectory of Assets/Resources.

This class is used by the loadfile and require functions in Lua.

Constructor & Destructor Documentation

◆ ScriptLoader()

uLua.ScriptLoader.ScriptLoader ( string  AssetsPath)
inline

Initializes a new instance of the uLua.ScriptLoader class.

Parameters
AssetsPathThe path, relative to Assets/Resources. For example if your scripts are stored under Assets/Resources/Scripts/, you should pass the value "Scripts/".

Member Function Documentation

◆ LoadFile()

override object uLua.ScriptLoader.LoadFile ( string  file,
Table  globalContext 
)
inline

Opens a file for reading the script code. It can return either a string, a byte[] or a Stream. If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place.

Parameters
fileThe file.
globalContextThe global context.
Returns
A string, a byte[] or a Stream.
Exceptions
System.ExceptionUnityAssetsScriptLoader.LoadFile : Cannot load + file

◆ ScriptFileExists()

override bool uLua.ScriptLoader.ScriptFileExists ( string  file)
inline

Checks if a given file exists.

Parameters
fileThe file.
Returns
True if the file exists, false if it does not.