Пример #1
0
    private IEnumerator BeginInitialize()
    {
        if (mStatus == LoadStatus.Done)
        {
            yield break;
        }
        else if (mStatus == LoadStatus.Loading)
        {
            yield return(new WaitUntil(() => mStatus == LoadStatus.Done));
        }
        else
        {
            mStatus = LoadStatus.Loading;
            //初始化资源列表
            yield return(AssetPath.Initialize());

            if (AssetPath.mode == AssetMode.AssetBundle)
            {
                BundleAsset bundle = GetOrCreateBundle <BundleAsset>(AssetPath.list.manifest);

                AssetLoadTask <AssetBundleManifest> task = new AssetLoadTask <AssetBundleManifest>(AssetPath.list.manifest, FinishInitialize);

                task.assetName = "AssetBundleManifest";

                yield return(bundle.LoadAssetAsync(task));
            }
            else
            {
                FinishInitialize(null);
            }
        }
    }
Пример #2
0
    private IEnumerator LoadAssetAsync <T>(IAssetLoadTask <T> task) where T : UnityEngine.Object
    {
        if (mStatus != LoadStatus.Done)
        {
            yield return(BeginInitialize());
        }


        BundleAsset bundle = GetOrCreateBundle <BundleAsset>(task.bundleName);

        yield return(bundle.LoadAssetAsync(task));
    }