/// <summary>
        /// 内存不足时调用
        /// </summary>
        private void OnLowMemory()
        {
            Log.Info("Low memory reported");
            ObjectPoolComponent objectPoolComponent = GameEntry.GetComponent <ObjectPoolComponent>();

            if (objectPoolComponent != null)
            {
                objectPoolComponent.ReleaseAllUnused();
            }
        }
 static int ReleaseAllUnused(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityGameFramework.Runtime.ObjectPoolComponent obj = (UnityGameFramework.Runtime.ObjectPoolComponent)ToLua.CheckObject(L, 1, typeof(UnityGameFramework.Runtime.ObjectPoolComponent));
         obj.ReleaseAllUnused();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #3
0
            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();
            }
Beispiel #4
0
        private void OnLowMemory()
        {
            Log.Info("Low memory reported...");

            ObjectPoolComponent objectPoolComponent = GameEntry.GetComponent <ObjectPoolComponent>();

            if (objectPoolComponent != null)
            {
                objectPoolComponent.ReleaseAllUnused();
            }

            ResourceComponent resourceCompoent = GameEntry.GetComponent <ResourceComponent>();

            if (resourceCompoent != null)
            {
                resourceCompoent.ForceUnloadUnusedAssets(true);
            }
        }
            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();
            }