コード例 #1
0
    public void LoadAssetBundle(string ifsExtractPath)
    {
        if (this.m_isAssetBundle)
        {
            if (this.dependency != null && this.dependency.m_isAssetBundle && !this.dependency.IsAssetBundleLoaded())
            {
                this.dependency.LoadAssetBundle(ifsExtractPath);
            }
            if (this.m_assetBundleState != enAssetBundleState.Unload)
            {
                return;
            }
            this.m_useASyncLoadingData = false;
            string text = CFileManager.CombinePath(ifsExtractPath, this.m_pathInIFS);
            if (CFileManager.IsFileExist(text))
            {
                if (this.IsUnCompress())
                {
                    int num = 0;
                    while (true)
                    {
                        try
                        {
                            this.m_assetBundle = AssetBundle.CreateFromFile(text);
                        }
                        catch (Exception)
                        {
                            this.m_assetBundle = null;
                        }
                        if (this.m_assetBundle != null)
                        {
                            break;
                        }
                        Debug.Log(string.Concat(new object[]
                        {
                            "Create AssetBundle ",
                            text,
                            " From File Error! Try Count = ",
                            num
                        }));
                        num++;
                        if (num >= 3)
                        {
                            goto Block_10;
                        }
                    }
                    goto IL_FC;
Block_10:
                    CFileManager.s_delegateOnOperateFileFail(text, enFileOperation.ReadFile);
                    IL_FC :;
                }
                else
                {
                    this.m_assetBundle = AssetBundle.CreateFromMemoryImmediate(CFileManager.ReadFile(text));
                }
                if (this.m_assetBundle == null)
                {
                    string text2 = string.Empty;
                    try
                    {
                        text2 = CFileManager.GetFileMd5(text);
                    }
                    catch (Exception)
                    {
                        text2 = string.Empty;
                    }
                    string message = string.Format("Load AssetBundle {0} Error!!! App version = {1}, Build = {2}, Reversion = {3}, Resource version = {4}, File md5 = {5}", new object[]
                    {
                        text,
                        CVersion.GetAppVersion(),
                        CVersion.GetBuildNumber(),
                        CVersion.GetRevisonNumber(),
                        CVersion.GetUsedResourceVersion(),
                        text2
                    });
                    Debug.Log(message);
                }
            }
            else
            {
                Debug.Log("File " + text + " can not be found!!!");
            }
            this.m_assetBundleState = enAssetBundleState.Loaded;
        }
    }