Esempio n. 1
0
    public static void BuildLua()
    {
        SLua.LuaState l = new SLua.LuaState();
        foreach (string file in Directory.GetFiles(Path.GetFullPath(Application.dataPath), "*.lua", SearchOption.AllDirectories))
        {
            if (file.StartsWith(Path.GetFullPath(Application.streamingAssetsPath)))
            {
                continue;
            }
            string output = file.Replace(Path.GetFullPath(Application.dataPath), "");
            output = Application.streamingAssetsPath + output;

            output = Path.GetFullPath(output);

            //Debug.LogError(Path.GetDirectoryName(output));

            Directory.CreateDirectory(Path.GetDirectoryName(output));

            l.doString(string.Format(@"
                                local f = io.open('{0}', 'wb')
                                local s = io.open('{1}')
                                f:write(string.dump(loadstring(s:read('*a'), '{1}')))
                                f:close()
                                s:close()
                        ", output.Replace(@"\", @"/"), file.Replace(@"\", @"/")));
        }

        l.Dispose();
        AssetDatabase.Refresh();
    }
Esempio n. 2
0
        // make sure lua state finalize at last
        // make sure LuaSvrGameObject excute order is max(9999)
        void OnDestroy()
        {
            if (state != null)
            {
                if (di != null)
                {
                    di.close();
                    di = null;
                }

                state.Dispose();
                state = null;
            }
        }
Esempio n. 3
0
        public void Dispose()
        {
            GC();
#if !SLUA_STANDALONE
            if (lgo != null)
            {
                GameObject.DestroyImmediate(lgo.gameObject);
            }
#endif
            if (luaState != null)
            {
                luaState.Dispose();
                luaState = null;
            }
        }