Exemplo n.º 1
0
        static Asset LoadInternal(string path, System.Type type, bool asyncMode)
        {
            path = path.ToLower();
            Asset asset = assets.Find(obj => { return(obj.assetPath == path); });

            if (asset == null)
            {
                var bundleName = Bundles.GetBundleName(path);
#if UNITY_EDITOR
                if (LoadType == AssetType.LocalAsset)
                {
                    asset = new Asset(path, bundleName?.bundleName, type);
                }
                else
#endif
                if (true)
                {
                    if (asyncMode)
                    {
                        asset = new BundleAssetAsync(path, bundleName?.bundleName, type);
                    }
                    else
                    {
                        asset = new BundleAsset(path, bundleName?.bundleName, type);
                    }
                }
                //处理正在卸载的情况
                if (AsyncOperationUnloadUnusedAssets != null)
                {
                    var tick = DateTime.Now.Ticks;
                    Debug.Log("Wait UnloadUnusedAssets Begin");
                    if (asyncMode)
                    {
                        Instance.StartCoroutine(Instance.AssetInitialize(asset));
                    }
                    else
                    {
                        while (!AsyncOperationUnloadUnusedAssets.isDone)
                        {
                            Thread.Yield();
                        }
                    }
                    Debug.Log("Wait UnloadUnusedAssets End use :" + (DateTime.Now.Ticks - tick));
                }
                else
                {
                    asset.Initialize();
                }
                assets.Add(asset);
            }
            asset.Load();
            return(asset);
        }
Exemplo n.º 2
0
 public static bool Exists(string path)
 {
     path = path.ToLower();
     return(Bundles.GetBundleName(path) != null);
 }