Esempio 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);
        }
Esempio n. 2
0
        /// <summary>
        /// Collect all KEngine's resource unused loaders
        /// </summary>
        public static void Collect()
        {
            while (AbstractResourceLoader.UnUsesLoaders.Count > 0)
            {
                AbstractResourceLoader.DoGarbageCollect();
            }

            Resources.UnloadUnusedAssets();
            System.GC.Collect();
            Debug.Log("ResManager GC Collect!");
        }
        public static T GetLoader <T>(string url) where T : AbstractResourceLoader
        {
            var dict = GetTypeDict(typeof(T));
            AbstractResourceLoader loader = null;

            if (dict.TryGetValue(url, out loader))
            {
                return((T)loader);
            }
            return(null);
        }
Esempio 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!");
        }
Esempio n. 5
0
 private void Update()
 {
     AbstractResourceLoader.CheckGcCollect();
 }