public void Initialize() { if (initialized) { return; } initialized = true; if (BattleID <= 0 || BattleID > TotalBattleNum) { Logger.LogWarning("Battle ID should be in range [1, " + TotalBattleNum + "], but is: " + BattleID + ". Let's make it default to 1."); BattleID = 1; } var path = string.Format("{0}/{1}", BasePath, BattleID); var battle = ResoucesManager.Instance.Load<GameObject>(path); if (battle == null) { Logger.LogError("Could not find path: " + path + " to generator battleground."); return; } if (Parent == null) { Logger.LogError("Parent should not be null."); return; } InitializeSounds(); var battlegroundObject = NGUITools.AddChild(Parent, battle); battlegroundLooper = battlegroundObject.GetComponent<AbstractBattlegroundLooper>(); }
public void Cleanup() { if (!initialized) { return; } initialized = false; Destroy(battlegroundLooper.gameObject); battlegroundLooper = null; CleanupSounds(); // with memeory strategy enabled will call unload unused assets over there. if (!MemoryStrategy.Instance.Enabled) { Resources.UnloadUnusedAssets(); } }