Exemple #1
0
    /// <summary>
    /// 同步加载资源
    /// </summary>
    private void loadAssetSync()
    {
        //通过资源名(即AB名)定位相关资源
        var assetspath = AssetDatabase.GetAssetPathsFromAssetBundle(AssetBundleName);

        if (assetspath.Length == 0)
        {
            ResourceLogger.logErr(string.Format("找不到资源名 : {0}的资源!", AssetBundleName));
        }
        else
        {
            mResourceInfo = createAssetDatabaseInfo(AssetBundleName, assetspath);
            mResourceInfo.updateLastUsedTime();
        }

        ///AssetDatabase模式下没有依赖资源的概念,
        ///所以一口气回调资源加载任务完成和上层逻辑回调
        LoadState = ResourceLoadState.SelfComplete;
        LoadSelfResourceCompleteNotifier(this);
        LoadSelfResourceCompleteNotifier = null;

        LoadState = ResourceLoadState.AllComplete;
        mResourceInfo.mIsReady = true;
        LoadResourceCompleteCallBack(mResourceInfo);
        LoadResourceCompleteCallBack = null;

        // 资源加载完成后,AssetDatabaseLoader的任务就完成了,回收重用
        AssetDatabaseLoaderFactory.recycle(this);
    }
Exemple #2
0
    /// <summary>
    /// 同步加载资源
    /// </summary>
    private void loadAssetSync()
    {
        if (string.IsNullOrEmpty(AssetBundlePath))
        {
            ResourceLogger.logErr(string.Format("找不到资源名 : {0}的资源!", AssetBundlePath));
        }
        else
        {
            mResourceInfo = createAssetDatabaseInfo(AssetBundlePath);
            mResourceInfo.updateLastUsedTime();
        }

        ///AssetDatabase模式下没有依赖资源的概念,
        ///所以一口气回调资源加载任务完成和上层逻辑回调
        LoadState = ResourceLoadState.SelfComplete;
        LoadSelfResourceCompleteNotifier(this);
        LoadSelfResourceCompleteNotifier = null;

        LoadState = ResourceLoadState.AllComplete;
        mResourceInfo.mIsReady = true;
        LoadResourceCompleteCallBack(mResourceInfo);
        LoadResourceCompleteCallBack = null;

        // 资源加载完成后,AssetDatabaseLoader的任务就完成了,回收重用
        AssetDatabaseLoaderFactory.recycle(this);
    }