Inheritance: IDisposable
示例#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;
        }
    }
示例#2
0
文件: LuaClient.cs 项目: benbon/tolua
 LuaEvent GetEvent(string name)
 {
     LuaTable table = luaState.GetTable(name);
     LuaEvent e = new LuaEvent(table);
     table.Dispose();
     table = null;
     return e;
 }
示例#3
0
文件: LuaClient.cs 项目: benbon/tolua
	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;
        }
示例#6
0
文件: LuaClient.cs 项目: benbon/tolua
    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;
        }
    }
示例#7
0
文件: LuaClient.cs 项目: benbon/tolua
 void SafeRelease(ref LuaEvent luaEvent)
 {
     if (luaEvent != null)
     {
         luaEvent.Dispose();
         luaEvent = null;
     }
 }
示例#8
0
 void Start()
 {
     try
     {
         UpdateEvent = GetEvent("UpdateBeat");
         LateUpdateEvent = GetEvent("LateUpdateBeat");
         FixedUpdateEvent = GetEvent("FixedUpdateBeat");
     }
     catch (Exception e)
     {
         Destroy(this);
         throw e;
     }
 }
示例#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;
    }