/// <summary> /// 游戏框架组件初始化。 /// </summary> protected override void Awake() { base.Awake(); Log.SetLogCallback(LogCallback); Log.Info("Game Framework version is {0}. Unity Game Framework version is {1}.", GameFrameworkEntry.Version, GameEntry.Version); #if !UNITY_5_3 && !UNITY_5_3_OR_NEWER Log.Error("Game Framework only applies with Unity 5.3 and above, but current Unity version is {0}.", Application.unityVersion); GameEntry.Shutdown(ShutdownType.Quit); #else InitZipHelper(); InitJsonHelper(); Utility.Converter.ScreenDpi = Screen.dpi; if (Utility.Converter.ScreenDpi <= 0) { Utility.Converter.ScreenDpi = DefaultDpi; } m_EditorResourceMode &= Application.isEditor; if (m_EditorResourceMode) { Log.Info("During this run, Game Framework will use editor resource files, which you should validate first."); } Application.targetFrameRate = m_FrameRate; Time.timeScale = m_GameSpeed; Application.runInBackground = m_RunInBackground; Screen.sleepTimeout = m_NeverSleep ? SleepTimeout.NeverSleep : SleepTimeout.SystemSetting; #endif }
protected override void OnDrawScrollableWindow() { GUILayout.Label("<b>Operations</b>"); GUILayout.BeginVertical("box"); { ObjectPoolComponent objectPoolComponent = GameEntry.GetComponent <ObjectPoolComponent>(); if (objectPoolComponent != null) { if (GUILayout.Button("Object Pool Release", GUILayout.Height(30f))) { objectPoolComponent.Release(); } if (GUILayout.Button("Object Pool Release All Unused", GUILayout.Height(30f))) { objectPoolComponent.ReleaseAllUnused(); } } ResourceComponent resourceCompoent = GameEntry.GetComponent <ResourceComponent>(); if (resourceCompoent != null) { if (GUILayout.Button("Unload Unused Assets", GUILayout.Height(30f))) { resourceCompoent.ForceUnloadUnusedAssets(false); } if (GUILayout.Button("Unload Unused Assets and Garbage Collect", GUILayout.Height(30f))) { resourceCompoent.ForceUnloadUnusedAssets(true); } } if (GUILayout.Button("Shutdown Game Framework (None)", GUILayout.Height(30f))) { GameEntry.Shutdown(ShutdownType.None); } if (GUILayout.Button("Shutdown Game Framework (Restart)", GUILayout.Height(30f))) { GameEntry.Shutdown(ShutdownType.Restart); } if (GUILayout.Button("Shutdown Game Framework (Quit)", GUILayout.Height(30f))) { GameEntry.Shutdown(ShutdownType.Quit); } } GUILayout.EndVertical(); }
protected override void OnDrawScrollableWindow() { GUILayout.Label("<b>Operation Settings</b>"); GUILayout.BeginVertical("box"); { ObjectPoolComponent objectPoolComponent = GameEntry.GetComponent <ObjectPoolComponent>(); if (objectPoolComponent != null) { if (GUILayout.Button("Object Pool Release", GUILayout.Height(30f))) { objectPoolComponent.Release(); } if (GUILayout.Button("Object Pool Release All Unused", GUILayout.Height(30f))) { objectPoolComponent.ReleaseAllUnused(); } } ResourceComponent resourceCompoent = GameEntry.GetComponent <ResourceComponent>(); if (resourceCompoent != null) { if (GUILayout.Button("Unload Unused Assets", GUILayout.Height(30f))) { resourceCompoent.UnloadUnusedAssets(false, "release from debugger"); } if (GUILayout.Button("Unload Unused Assets and Garbage Collect", GUILayout.Height(30f))) { resourceCompoent.UnloadUnusedAssets(true, "release from debugger"); } } if (GUILayout.Button("Restart Game Framework", GUILayout.Height(30f))) { GameEntry.Restart(); } if (GUILayout.Button("Shutdown Game Framework", GUILayout.Height(30f))) { GameEntry.Shutdown(); } } GUILayout.EndVertical(); }
/// <summary> /// 游戏框架组件初始化。 /// </summary> protected override void Awake() { base.Awake(); InitTextHelper(); InitVersionHelper(); InitLogHelper(); Log.Info("Game Framework Version: {0}", GameFramework.Version.GameFrameworkVersion); Log.Info("Game Version: {0} ({1})", GameFramework.Version.GameVersion, GameFramework.Version.InternalGameVersion); Log.Info("Unity Version: {0}", Application.unityVersion); #if UNITY_5_3_OR_NEWER || UNITY_5_3 InitCompressionHelper(); InitJsonHelper(); Utility.Converter.ScreenDpi = Screen.dpi; if (Utility.Converter.ScreenDpi <= 0) { Utility.Converter.ScreenDpi = DefaultDpi; } m_EditorResourceMode &= Application.isEditor; if (m_EditorResourceMode) { Log.Info("During this run, Game Framework will use editor resource files, which you should validate first."); } Application.targetFrameRate = m_FrameRate; Time.timeScale = m_GameSpeed; Application.runInBackground = m_RunInBackground; Screen.sleepTimeout = m_NeverSleep ? SleepTimeout.NeverSleep : SleepTimeout.SystemSetting; #else Log.Error("Game Framework only applies with Unity 5.3 and above, but current Unity version is {0}.", Application.unityVersion); GameEntry.Shutdown(ShutdownType.Quit); #endif #if UNITY_5_6_OR_NEWER Application.lowMemory += OnLowMemory; #endif }