public static Script LoadScript() { Script.DefaultOptions.ScriptLoader = new UnityAssetsScriptLoader("MoonSharp/Scripts/"); var paths = new UnityAssetsScriptLoader("MoonSharp/Scripts/"); ((ScriptLoaderBase)Script.DefaultOptions.ScriptLoader).ModulePaths = paths.ModulePaths; // Debug.LogError(paths.ModulePaths.Length); // new string[] { "MoonSharp/Scripts/mover/?", "MoonSharp/Scripts/mover/?.txt" }; var _main = new Script(); ((ScriptLoaderBase)_main.Options.ScriptLoader).ModulePaths = new string[] { "MoonSharp/Scripts/?", "MoonSharp/Scripts/?.txt" }; //paths.ModulePaths; //((ScriptLoaderBase)_main.Options.ScriptLoader).ModulePaths = // ScriptLoaderBase.UnpackStringPaths("MoonSharp/Scripts/mover/?;MoonSharp/Scripts/mover?.lua"); // ((ScriptLoaderBase)_main.Options.ScriptLoader).ModulePaths = //new string[] { "MoonSharp/Scripts/mover/?", "MoonSharp/Scripts/mover/?.lua" }; _main.DoFile("Lua"); return(_main); }
protected override void Awake() { base.Awake(); Dictionary <string, string> scripts = new Dictionary <string, string>(); TextAsset[] result = Resources.LoadAll <TextAsset>("Lua"); for (int i = 0; i < result.Length; i++) { scripts.Add(result[i].name, result[i].text); } var scriptLoader = new UnityAssetsScriptLoader(scripts); Script.DefaultOptions.ScriptLoader = scriptLoader; UserData.RegisterType <LuaShotPattern>(); }