|
|
@ -12,9 +12,19 @@ using MoonSharp.RemoteDebugger; |
|
|
|
|
|
|
|
|
|
|
|
namespace Fungus |
|
|
|
namespace Fungus |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
public class LuaEnvironment : MonoBehaviour |
|
|
|
public class LuaEnvironment : MonoBehaviour |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Helper class used to extend the initialization behavior of LuaEnvironment. |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public abstract class Initializer : MonoBehaviour |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Called when the LuaEnvironment is initializing. |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public abstract void Initialize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Custom file loader for MoonSharp that loads in all Lua scripts in the project. |
|
|
|
/// Custom file loader for MoonSharp that loads in all Lua scripts in the project. |
|
|
|
/// Scripts must be placed in a Resources/Lua directory. |
|
|
|
/// Scripts must be placed in a Resources/Lua directory. |
|
|
@ -127,13 +137,14 @@ namespace Fungus |
|
|
|
// You can restrict which core lua modules are available here if needed. See the MoonSharp documentation for details. |
|
|
|
// You can restrict which core lua modules are available here if needed. See the MoonSharp documentation for details. |
|
|
|
interpreter = new Script(CoreModules.Preset_Complete); |
|
|
|
interpreter = new Script(CoreModules.Preset_Complete); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load all Lua scripts in the project |
|
|
|
InitLuaScriptFiles(); |
|
|
|
InitLuaScriptFiles(); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Use an interface here instead |
|
|
|
// Initialize any attached initializer components (e.g. LuaUtils) |
|
|
|
LuaUtils luaUtils = GetComponent<LuaUtils>(); |
|
|
|
Initializer[] initializers = GetComponentsInChildren<Initializer>(); |
|
|
|
if (luaUtils != null) |
|
|
|
foreach (Initializer initializer in initializers) |
|
|
|
{ |
|
|
|
{ |
|
|
|
luaUtils.Initialise(); |
|
|
|
initializer.Initialize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (remoteDebugger) |
|
|
|
if (remoteDebugger) |
|
|
|