protected void OnDestroy() { if (ms_Instance == this) // avoid multiple System { DestroyImmediate(m_SceneFSM); m_SceneFSM = null; m_Localization.Dispose(); m_Localization = null; DestroyImmediate(m_Input); m_Input = null; m_DebugView = null; m_Config.Dispose(); m_Config = null; m_PerformanceStatistics.LogAndRecord(); m_LogRecord.Dispose(); m_LogRecord = null; m_AssetLoader = null; m_PerformanceStatistics.Dispose(); m_PerformanceStatistics = null; ms_Instance = null; } }
private IEnumerator Initialize_Co() { if (SystemInitializer.EnablePerformanceStatistics) { m_PerformanceStatistics = new hwmPerformanceStatistics(); } else { m_PerformanceStatistics = new hwmEmptyPerformanceStatistics(); } m_PerformanceStatistics.Initialize(); m_LogRecord = new hwmLogRecord(); #if UNITY_EDITOR m_LogRecord.Initialize(byte.MaxValue, true); #else m_LogRecord.Initialize((1 << (byte)LogType.Assert) | (1 << (byte)LogType.Assert) | (1 << (byte)LogType.Exception) | (1 << (byte)LogType.Error) | (1 << (byte)LogType.Warning) | (1 << (byte)LogType.Log) , false); #endif yield return(null); m_AssetLoader = new hwmAssetLoader(); yield return(null); m_Config = new hwmINIParser(); TextAsset configTextAsset = m_AssetLoader.LoadAsset(hwmAssetLoader.AssetType.System, SystemInitializer.ConfigAssetName) as TextAsset; m_Config.Initialize(configTextAsset.text); System.Text.StringBuilder configLogString = new System.Text.StringBuilder(512); configLogString.AppendLine("Loaded Config"); foreach (KeyValuePair <string, string> kv in m_Config.GetConfig()) { configLogString.AppendLine(string.Format("{0}={1}", kv.Key, kv.Value)); } Debug.Log(configLogString.ToString()); yield return(null); bool enableDebugView; if (m_Config.TryGetBoolValue("Enable_DebugView", out enableDebugView) && enableDebugView) { m_DebugView = InstantiatePrefabAndSetParentThisTransform <hwmDebugView>(m_AssetLoader.LoadAsset(hwmAssetLoader.AssetType.System, SystemInitializer.DebugViewAssetName)); } m_Input = InstantiatePrefabAndSetParentThisTransform <hwmInput>(m_AssetLoader.LoadAsset(hwmAssetLoader.AssetType.System, SystemInitializer.InputAssetName)); yield return(null); m_Localization = new hwmLocalization(); m_Localization.Initialize(m_AssetLoader.LoadAsset(hwmAssetLoader.AssetType.System, SystemInitializer.LocalizationAssetName) as TextAsset); yield return(null); Instantiate(m_AssetLoader.LoadAsset(hwmAssetLoader.AssetType.Game, "World")); m_SceneFSM = InstantiatePrefabAndSetParentThisTransform <hwmSceneFSM>(m_AssetLoader.LoadAsset(hwmAssetLoader.AssetType.System, SystemInitializer.SceneFSMAssetName)); yield return(StartCoroutine(m_SceneFSM.EnterStartupScene())); }