예제 #1
0
    public void LoadAssetBundle(string ifsExtractPath)
    {
        if (!m_isAssetBundle)
        {
            return;
        }
        if (dependency != null && dependency.m_isAssetBundle && !dependency.IsAssetBundleLoaded())
        {
            dependency.LoadAssetBundle(ifsExtractPath);
        }
        if (m_assetBundleState != enAssetBundleState.Unload)
        {
            return;
        }
        m_useAsyncLoadingData = false;
        string filePath = FileManager.CombinePath(ifsExtractPath, m_pathInIFS);

        if (FileManager.IsFileExist(filePath))
        {
            int num = 0;
            while (true)
            {
                try
                {
                    m_assetBundle = AssetBundle.LoadFromFile(filePath);
                }
                catch (Exception)
                {
                    m_assetBundle = null;
                }
                if (this.m_assetBundle != null)
                {
                    break;
                }
                num++;
                if (num >= 3)
                {
                    break;
                }
            }

            if (m_assetBundle == null)
            {
                Debug.LogError("Load AssetBundle " + filePath + " Error!!!");
            }
        }
        else
        {
            Debug.LogError("File " + filePath + " can not be found!!!");
        }
        m_assetBundleState = enAssetBundleState.Loaded;
    }
예제 #2
0
    public IEnumerator AsyncLoadAssetBundle(string ifsExtractPath)
    {
        if (m_isAssetBundle)
        {
            yield break;
        }

        m_useAsyncLoadingData = true;
        m_assetBundleState    = enAssetBundleState.Loading;

        AssetBundleCreateRequest assetBundleLoader = AssetBundle.LoadFromFileAsync(FileManager.CombinePath(ifsExtractPath, m_pathInIFS));

        yield return(assetBundleLoader);

        if (m_useAsyncLoadingData)
        {
            m_assetBundle = assetBundleLoader.assetBundle;
        }
        m_assetBundleState = enAssetBundleState.Loaded;
    }
예제 #3
0
 public void UnloadAssetBundle(bool force = false)
 {
     if (m_isAssetBundle && (!IsResident() || force))
     {
         if (m_assetBundleState == enAssetBundleState.Loaded)
         {
             if (m_assetBundle != null)
             {
                 m_assetBundle.Unload(false);
                 m_assetBundle = null;
             }
             m_assetBundleState = enAssetBundleState.Unload;
         }
         else if (m_assetBundleState == enAssetBundleState.Loading)
         {
             m_useAsyncLoadingData = false;
         }
         if (dependency != null)
         {
             dependency.UnloadAssetBundle(force);
         }
     }
 }
예제 #4
0
 public CResourcePackerInfo(bool isAssetBundle)
 {
     this.m_isAssetBundle       = isAssetBundle;
     this.m_assetBundleState    = enAssetBundleState.Unload;
     this.m_useASyncLoadingData = false;
 }
예제 #5
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;
        }
    }