protected override void OnStart() { m_lua.AddLoader(LuaFileLoader); object[] ret = null; ret = m_lua.DoString(string.Format("entrance_arg_str = '{0}' ", m_owner.app.root.lua_main_args)); ret = m_lua.DoString(" require 'prepare_env' "); // ret = m_lua.DoString(string.Format(" {0}('{1}') ", m_owner.app.root.lua_main_fn, m_owner.app.root.lua_main_args)); }
public override void OnInstance() { m_luaVM = new XLua.LuaEnv(); m_luaVM.AddLoader(ResourceLoader.LoadLua); m_luaVM.GcPause = 100; m_luaVM.GcStepmul = 5000; }
// Start is called before the first frame update void Start() { Debug.Assert(Singleton == null); Singleton = this; DontDestroyOnLoad(this.gameObject); m_luaEnv = new XLua.LuaEnv(); m_luaEnv.AddLoader(xLuaLoader.LoadFromResource); m_luaEnv.Global.Set("launch_file", ms_launchFile); m_luaEnv.DoString(Resources.Load <TextAsset>("runtime").text, "runtime"); }
public static void OnCreateServerSkillTime() { //遍历文件夹 string path = AssetBundleUtility.PackagePathToAssetsPath("Lua"); string AssetbundleName = AssetBundleUtility.AssetBundlePathToAssetBundleName(path); XLua.LuaEnv luaEnv = new XLua.LuaEnv(); luaEnv.AddLoader(CustomLoader); luaEnv.AddBuildin("pb", XLua.LuaDLL.Lua.LoadPb); luaEnv.AddBuildin("cjson", XLua.LuaDLL.Lua.LoadRapidJson); string cmd = string.Format("require('{0}/Editor/AssetBundle/SkillTimeline')", Application.dataPath); luaEnv.DoString(cmd); XLua.LuaFunction func = luaEnv.Global.Get <XLua.LuaFunction>("ParseSkillTime"); object[] obj = func.Call(); if (obj != null && obj.Length > 0) { string serverPath = string.Format("{0}/{1}.txt", Application.dataPath.Substring(0, Application.dataPath.Length - 7), "normal_timeline"); if (File.Exists(serverPath)) { File.Delete(serverPath); } FileStream fs = new FileStream(serverPath, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.Write("id" + "\t" + "roleId" + "\t" + "key" + "\t" + "time"); sw.WriteLine(); sw.Write("int" + "\t" + "int" + "\t" + "string" + "\t" + "float"); sw.WriteLine(); XLua.LuaTable tempTable = obj[0] as XLua.LuaTable; int index = 1; tempTable.ForEach <int, XLua.LuaTable>(delegate(int a, XLua.LuaTable luaTable) { sw.Write(index + "\t" + luaTable.Get <int>("roldId") + "\t" + luaTable.Get <string>("key") + "\t" + luaTable.Get <float>("time")); sw.WriteLine(); index++; }); sw.Close(); fs.Close(); } func = luaEnv.Global.Get <XLua.LuaFunction>("ParseCSkillTime"); obj = func.Call(); if (obj != null && obj.Length > 0) { string serverPath = string.Format("{0}/{1}.txt", Application.dataPath.Substring(0, Application.dataPath.Length - 7), "cc_timeline"); if (File.Exists(serverPath)) { File.Delete(serverPath); } FileStream fs = new FileStream(serverPath, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.Write("id" + "\t" + "key" + "\t" + "time"); sw.WriteLine(); sw.Write("int" + "\t" + "string" + "\t" + "float"); sw.WriteLine(); XLua.LuaTable tempTable = obj[0] as XLua.LuaTable; int index = 1; tempTable.ForEach <int, XLua.LuaTable>(delegate(int a, XLua.LuaTable luaTable) { sw.Write(index + "\t" + luaTable.Get <string>("key") + "\t" + luaTable.Get <float>("time")); sw.WriteLine(); index++; }); sw.Close(); fs.Close(); } }
static Patch() { patchLuaEnv = new XLua.LuaEnv(); patchLuaEnv.AddLoader(PatchLuaLoader); }