コード例 #1
0
        /// <summary>
        /// 异步加载场景
        /// </summary>
        public AssetOperationHandle LoadSceneAsync(string location, SceneInstanceParam instanceParam)
        {
            string         sceneName   = Path.GetFileName(location);
            FileLoaderBase cacheLoader = AssetSystem.CreateLoader(location);
            var            handle      = cacheLoader.LoadSceneAsync(sceneName, instanceParam);

            return(handle);
        }
コード例 #2
0
        /// <summary>
        /// 强制回收所有资源
        /// </summary>
        public static void ForceUnloadAllAssets()
        {
            for (int i = 0; i < _loaders.Count; i++)
            {
                FileLoaderBase loader = _loaders[i];
                loader.Destroy(false);
            }
            _loaders.Clear();

            // 释放所有资源
            Resources.UnloadUnusedAssets();
        }
コード例 #3
0
 /// <summary>
 /// 资源回收(卸载引用计数为零的资源)
 /// </summary>
 public static void UnloadUnusedAssets()
 {
     for (int i = _loaders.Count - 1; i >= 0; i--)
     {
         FileLoaderBase loader = _loaders[i];
         if (loader.CanDestroy())
         {
             loader.Destroy(true);
             _loaders.RemoveAt(i);
         }
     }
 }
コード例 #4
0
 /// <summary>
 /// 实时销毁场景
 /// 注意:因为场景比较特殊,需要立刻回收
 /// </summary>
 private static void UpdateDestroyScene()
 {
     for (int i = _loaders.Count - 1; i >= 0; i--)
     {
         FileLoaderBase loader = _loaders[i];
         if (loader.IsSceneLoader && loader.CanDestroy())
         {
             loader.Destroy(true);
             _loaders.RemoveAt(i);
         }
     }
 }
コード例 #5
0
        private AssetOperationHandle LoadSubAssetsInternal(string location, System.Type assetType, bool waitForAsyncComplete)
        {
            string         assetName   = Path.GetFileName(location);
            FileLoaderBase cacheLoader = AssetSystem.CreateLoader(location);
            var            handle      = cacheLoader.LoadSubAssetsAsync(assetName, assetType, waitForAsyncComplete);

            if (waitForAsyncComplete)
            {
                cacheLoader.WaitForAsyncComplete();
            }
            return(handle);
        }
コード例 #6
0
        /// <summary>
        /// 从列表里获取加载器
        /// </summary>
        private static FileLoaderBase TryGetLoader(string bundleName)
        {
            FileLoaderBase loader = null;

            for (int i = 0; i < _loaders.Count; i++)
            {
                FileLoaderBase temp = _loaders[i];
                if (temp.BundleInfo.BundleName.Equals(bundleName))
                {
                    loader = temp;
                    break;
                }
            }
            return(loader);
        }
コード例 #7
0
        internal static FileLoaderBase CreateLoaderInternal(AssetBundleInfo bundleInfo)
        {
            // 如果加载器已经存在
            FileLoaderBase loader = TryGetLoader(bundleInfo.BundleName);

            if (loader != null)
            {
                return(loader);
            }

            // 创建加载器
            if (SimulationOnEditor)
            {
                loader = new AssetDatabaseLoader(bundleInfo);
            }
            else
            {
                loader = new AssetBundleLoader(bundleInfo);
            }

            // 新增下载需求
            _loaders.Add(loader);
            return(loader);
        }
コード例 #8
0
 public AssetBundleProvider(FileLoaderBase owner, string assetName, System.Type assetType)
     : base(owner, assetName, assetType)
 {
     _loader = owner as AssetBundleLoader;
 }
コード例 #9
0
 public AssetSceneProvider(FileLoaderBase owner, string assetName, SceneInstanceParam param)
     : base(owner, assetName, null)
 {
     _param = param;
 }
コード例 #10
0
 public AssetDatabaseProvider(FileLoaderBase owner, string assetName, System.Type assetType)
     : base(owner, assetName, assetType)
 {
 }