Inheritance: IDisposable
Exemplo 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;
        }
    }
Exemplo n.º 2
0
 LuaEvent GetEvent(string name)
 {
     LuaTable table = luaState.GetTable(name);
     LuaEvent e = new LuaEvent(table);
     table.Dispose();
     table = null;
     return e;
 }
Exemplo 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");                
	}
Exemplo n.º 4
0
        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");     
        }
Exemplo n.º 5
0
        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;
        }
Exemplo 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;
        }
    }
Exemplo n.º 7
0
 void SafeRelease(ref LuaEvent luaEvent)
 {
     if (luaEvent != null)
     {
         luaEvent.Dispose();
         luaEvent = null;
     }
 }
Exemplo n.º 8
0
 void Start()
 {
     try
     {
         UpdateEvent = GetEvent("UpdateBeat");
         LateUpdateEvent = GetEvent("LateUpdateBeat");
         FixedUpdateEvent = GetEvent("FixedUpdateBeat");
     }
     catch (Exception e)
     {
         Destroy(this);
         throw e;
     }
 }
Exemplo 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;
    }