Inheritance: IDisposable
Esempio n. 1
0
    public void Destroy()
    {
        if (luaState != null)
        {
            if (UpdateEvent != null)
            {
                UpdateEvent.Dispose();
                UpdateEvent = null;
            }

            if (LateUpdateEvent != null)
            {
                LateUpdateEvent.Dispose();
                LateUpdateEvent = null;
            }

            if (FixedUpdateEvent != null)
            {
                FixedUpdateEvent.Dispose();
                FixedUpdateEvent = null;
            }

            luaState = null;
        }
    }
Esempio n. 2
0
 LuaEvent GetEvent(string name)
 {
     LuaTable table = luaState.GetTable(name);
     LuaEvent e = new LuaEvent(table);
     table.Dispose();
     table = null;
     return e;
 }
Esempio n. 3
0
	void Start () 
    {
        luaState.Start();
        luaState.DoFile("Main.lua");

        updateFunc = luaState.GetFunction("Update");
        lateUpdateFunc = luaState.GetFunction("LateUpdate");
        fixedUpdateFunc = luaState.GetFunction("FixedUpdate");
        levelLoaded = luaState.GetFunction("OnLevelWasLoaded");

        LuaFunction main = luaState.GetFunction("Main");
        main.Call();
        main.Dispose();
        main = null;

        UpdateEvent = GetEvent("UpdateBeat");
        LateUpdateEvent = GetEvent("LateUpdateBeat");
        FixedUpdateEvent = GetEvent("FixedUpdateBeat");                
	}
        public void InitStart() {
            InitLuaPath();
            InitLuaBundle();
            this.lua.Start();    //启动LUAVM

            lua.DoFile("Main.lua");

            updateFunc = lua.GetFunction("Update");
            lateUpdateFunc = lua.GetFunction("LateUpdate");
            fixedUpdateFunc = lua.GetFunction("FixedUpdate");

            LuaFunction main = lua.GetFunction("Main");
            main.Call();
            main.Dispose();
            main = null;

            UpdateEvent = GetEvent("UpdateBeat");
            LateUpdateEvent = GetEvent("LateUpdateBeat");
            FixedUpdateEvent = GetEvent("FixedUpdateBeat");     
        }
        public void Close() {
            SafeRelease(ref updateFunc);
            SafeRelease(ref lateUpdateFunc);
            SafeRelease(ref fixedUpdateFunc);

            if (UpdateEvent != null) {
                UpdateEvent.Dispose();
                UpdateEvent = null;
            }

            if (LateUpdateEvent != null) {
                LateUpdateEvent.Dispose();
                LateUpdateEvent = null;
            }

            if (FixedUpdateEvent != null) {
                FixedUpdateEvent.Dispose();
                FixedUpdateEvent = null;
            }
            lua.Dispose();
            lua = null;
            loader = null;
        }
Esempio n. 6
0
    void OnApplicationQuit()
    {
        if (luaState != null)
        {
            SafeRelease(ref updateFunc);
            SafeRelease(ref lateUpdateFunc);
            SafeRelease(ref fixedUpdateFunc);
            SafeRelease(ref levelLoaded);

            if (UpdateEvent != null)
            {
                UpdateEvent.Dispose();
                UpdateEvent = null;
            }

            if (LateUpdateEvent != null)
            {
                LateUpdateEvent.Dispose();
                LateUpdateEvent = null;
            }

            if (FixedUpdateEvent != null)
            {
                FixedUpdateEvent.Dispose();
                FixedUpdateEvent = null;
            }

            luaState.Dispose();
            luaState = null;
            Instance = null;
        }
    }
Esempio n. 7
0
 void SafeRelease(ref LuaEvent luaEvent)
 {
     if (luaEvent != null)
     {
         luaEvent.Dispose();
         luaEvent = null;
     }
 }
Esempio n. 8
0
 void Start()
 {
     try
     {
         UpdateEvent = GetEvent("UpdateBeat");
         LateUpdateEvent = GetEvent("LateUpdateBeat");
         FixedUpdateEvent = GetEvent("FixedUpdateBeat");
     }
     catch (Exception e)
     {
         Destroy(this);
         throw e;
     }
 }
Esempio n. 9
0
    LuaEvent GetEvent(string name)
    {
        LuaTable table = luaState.GetTable(name);

        if (table == null)
        {
            throw new LuaException(string.Format("Lua table {0} not exists", name));
        }

        LuaEvent e = new LuaEvent(table);
        table.Dispose();
        table = null;
        return e;
    }