private void OnDestroy() { if (luaGameManager != null) { if (luaGameManager.luaTable != null) { LuaFunction luaOnDestroy = luaGameManager.luaTable["OnDestroy"] as LuaFunction; if (luaOnDestroy != null) { luaOnDestroy.call(); } else { Debug.LogWarning("[GameManager]:; Miss OnDestroy function. LuaGameManger is:: " + luaGameManager.luaFileName); } } luaGameManager.luaTable = null; luaGameManager.luaFileName = ""; luaGameManager = null; } if (GInstance != null) { UnityEngine.SceneManagement.SceneManager.sceneLoaded -= onSceneLoaded; GInstance = null; } }
public void BindGameManager(LuaTable inTable, string luaFile) { if (luaGameManager == null) { luaGameManager = new FLuaBind(); } if (inTable != null && luaGameManager.luaTable == null) { luaGameManager.luaTable = inTable; luaGameManager.luaFileName = luaFile; } }
/// <summary> /// Bind lua game mode logic with level basic game mode component.if failed to bind, maybe game will not normally execute. /// this function must be invoked after lua game mode has been loaded. /// </summary> /// <param name="inGameMode">lua script table</param> /// <param name="luaGameModeFileName">name of lua script</param> /// <returns>return true if successfully band. otherwise false</returns> public bool BindLuaGameMode(LuaTable inGameMode, string luaGameModeFileName) { Debug.Log("[GameModeBase]::GameMode is " + luaGameModeFileName); if (luaGameMode != null) { if (luaGameMode.luaTable != null && luaGameMode.luaFileName.Equals(luaGameModeFileName)) { Debug.LogWarning("[GameModeBase]:: repeat band game mode logic.please check game code and fixed this. will return..... "); return(true); } if (luaGameMode.luaTable != null && !luaGameMode.luaFileName.Equals(luaGameModeFileName)) { Debug.LogError("[GameModeBase]:: repeat band game mode logic. are you sure re-bind game logic with " + luaGameModeFileName + "?? currently this was forbidden"); return(false); } } else { luaGameMode = new FLuaBind(); } if (inGameMode == null) { Debug.LogError("[GameModeBase]:: invalid game mode.... please try to fixed this"); return(false); } if (string.IsNullOrEmpty(luaGameModeFileName)) { Debug.LogWarning("[GameModeBase]:: invalid game mode file name. will allow game execution, but please fixed this bug as soon as possible"); } _gameState = EGameState.EGS_Start; luaGameMode.luaTable = inGameMode; luaGameMode.luaFileName = luaGameModeFileName; return(true); }