Ejemplo n.º 1
0
        public static KResourceLoaderDebugger Create(string type, string url, AbstractResourceLoader loader)
        {
            if (IsApplicationQuit)
            {
                return(null);
            }

            const string bigType = "ResourceLoaderDebuger";

            var newHelpGameObject = new GameObject(string.Format("{0}-{1}", type, url));

            KDebuggerObjectTool.SetParent(bigType, type, newHelpGameObject);
            var newHelp = newHelpGameObject.AddComponent <KResourceLoaderDebugger>();

            newHelp.TheLoader = loader;

            loader.DisposeEvent += () =>
            {
                if (!IsApplicationQuit)
                {
                    KDebuggerObjectTool.RemoveFromParent(bigType, type, newHelpGameObject);
                }
            };


            return(newHelp);
        }
        public static KResoourceLoadedAssetDebugger Create(string type, string url, object rawObj)
        {
            var mainAsset = rawObj as UnityEngine.Object;

            UnityEngine.Object[] allAssets = null;
            long totalSize = 0;

            if (mainAsset != null)
            {
                totalSize = UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(mainAsset);
            }
            else
            {
                allAssets = rawObj as UnityEngine.Object[];
                type      = allAssets[0].GetType().Name;

                foreach (var asset in allAssets)
                {
                    totalSize += UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(asset);
                }
            }

            var newHelpGameObject = new GameObject(string.Format("LoadedObject-{0}-{1}", type, url));

            KDebuggerObjectTool.SetParent(bigType, type, newHelpGameObject);

            var newHelp = newHelpGameObject.AddComponent <KResoourceLoadedAssetDebugger>();

            newHelp.Type       = type;
            newHelp.mainAsset  = mainAsset;
            newHelp.allAssets  = allAssets;
            newHelp.MemorySize = string.Format("{0:F5}KB", totalSize / 1024f);

            return(newHelp);
        }
 private void Update()
 {
     if (mainAsset == null && allAssets == null && !IsRemoveFromParent)
     {
         KDebuggerObjectTool.RemoveFromParent(bigType, Type, gameObject);
         IsRemoveFromParent = true;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 游戏重启时,释放ResManager加载的所有资源
        /// </summary>
        public static void Dispose()
        {
#if UNITY_EDITOR
            KDebuggerObjectTool.Dispose();
#endif
            AbstractResourceLoader.DisposeAll();
            BundleManifest = null;

            AssetBundle.UnloadAllAssetBundles(false);
            Resources.UnloadUnusedAssets();
            System.GC.Collect();
            Debug.Log("ResManager Dispose!");
        }