Beispiel #1
0
        public static string DbgPrint_BundleCount()
        {
            int num = 0;

            Holder.m_DebugMessage.Length = 0;
            Holder.m_DebugMessage.AppendLine("=======================================>");
            Holder.m_DebugMessage.AppendFormat("Bundle Stack Total Count({0}) CurIdx({1}) UseCache({1})\r\n", Holder._GetBundleGroupCount(), Holder.m_stackIP, Option.useCache);
            foreach (KeyValuePair <string, Dictionary <string, WWWItem> > current in Holder._EnumBundleGroupList())
            {
                string key = current.Key;
                Dictionary <string, WWWItem> value = current.Value;
                num += value.Count;
                Holder.m_DebugMessage.AppendFormat("Holder=\"{0}\", Cnt({1})\r\n", key, value.Count);
            }
            Holder.m_DebugMessage.AppendLine("----------------------------------------");
            Holder.m_DebugMessage.AppendFormat("Total bundle count = {0}\r\n", (num != 0) ? num.ToString("###,###,###,###") : "0");
            return(Holder.m_DebugMessage.ToString());
        }
Beispiel #2
0
        public static string DbgPrint_BundleList(string stackName)
        {
            int num = 0;

            Holder.m_DebugMessage.Length = 0;
            if (stackName == null)
            {
                Holder.m_DebugMessage.AppendLine("=======================================>");
                Holder.m_DebugMessage.AppendFormat("Bundle Stack Total Count({0}) CurIdx({1}) UseCache({2})\r\n", Holder._GetBundleGroupCount(), Holder.m_stackIP, Option.useCache);
            }
            else
            {
                Holder.m_DebugMessage.AppendLine("<< AssetBundles in stack >>");
            }
            foreach (KeyValuePair <string, Dictionary <string, WWWItem> > current in Holder._EnumBundleGroupList())
            {
                string key = current.Key;
                Dictionary <string, WWWItem> value = current.Value;
                if (stackName == null || stackName == key.ToLower())
                {
                    Holder.m_DebugMessage.AppendLine("----------------------------------------");
                    Holder.m_DebugMessage.AppendFormat("Holder = {0}, Cnt({1})\r\n", key, value.Count);
                    int num2 = 0;
                    foreach (KeyValuePair <string, WWWItem> current2 in value)
                    {
                        num2++;
                        string  key2     = current2.Key;
                        WWWItem value2   = current2.Value;
                        int     safeSize = value2.safeSize;
                        Holder.m_DebugMessage.AppendFormat("- {0}: Cache(Use:{1}, Hit:{2}, refCnt:{3}, Size:{4}) : {5}\r\n", new object[]
                        {
                            value2.stateString,
                            value2.useLoadFromCacheOrDownload,
                            value2.isCacheHit,
                            value2.refCnt,
                            (safeSize != 0) ? safeSize.ToString("###,###,###,###") : "0",
                            key2
                        });
                        num += safeSize;
                    }
                }
            }
            Holder.m_DebugMessage.AppendLine("----------------------------------------");
            Holder.m_DebugMessage.AppendFormat("Total size = {0} bytes\r\n", num.ToString("###,###,###,###"));
            return(Holder.m_DebugMessage.ToString());
        }
Beispiel #3
0
 public static string DbgPrint_BundleList()
 {
     return(Holder.DbgPrint_BundleList(null));
 }
Beispiel #4
0
 public static WWWItem TryGetOrCreateBundle(string key, string stackName)
 {
     return(Holder.TryGetOrCreateBundle(key, stackName, false));
 }
        public void _InternalOnly_ChangeStateSuccess()
        {
            this.wiState       = WWWItem.StateWI.SUCCESS;
            this.safeBundle    = null;
            this.safeBytes     = null;
            this.safeString    = null;
            this.safeAudioClip = null;
            if (this.useLoadFromCacheOrDownload)
            {
                this.safeSize = ((this.m_kItem == null) ? 0 : this.m_kItem.nFileSize);
            }
            else
            {
                this.safeSize = ((this.m_www == null) ? 0 : this.m_www.size);
            }
            bool flag = !this.isCacheHit && this.itemType == ItemType.UNDEFINED && this.UseCustomCache;

            if (flag)
            {
                if (Option.EnableTrace)
                {
                    TsLog.LogWarning("[TsBundle] set RawBytes => Cache Hit[{0}], Use[{1}] (AssetPath=\"{2}\", Stack=\"{3}\", Type={4})", new object[]
                    {
                        this.isCacheHit,
                        this.useLoadFromCacheOrDownload,
                        this.assetPath,
                        this.stackName,
                        this.itemType
                    });
                }
                this.rawBytes = this.m_www.bytes;
            }
            try
            {
                if (this.itemType == ItemType.USER_STRING)
                {
                    this.safeString = this.m_www.text;
                    if (this.safeString == null)
                    {
                        this._InternalOnly_ChangeStateErrorOrRetry("fail to access www.text.");
                    }
                }
                else if (this.itemType == ItemType.USER_BYTESA)
                {
                    this.safeBytes = ((this.rawBytes == null) ? this.m_www.bytes : this.rawBytes);
                    if (this.safeBytes == null)
                    {
                        this._InternalOnly_ChangeStateErrorOrRetry("fail to access www.bytes.");
                    }
                }
                else if (this.itemType == ItemType.USER_AUDIO)
                {
                    this.safeAudioClip = this.m_www.GetAudioClip(false, true);
                    if (null == this.safeAudioClip)
                    {
                        this._InternalOnly_ChangeStateErrorOrRetry("fail to access www.AudioClip.");
                    }
                }
                else if (this.itemType == ItemType.UNDEFINED)
                {
                    if (this.refCnt == 1)
                    {
                        this.Dispose();
                    }
                    if (this.m_kItem != null)
                    {
                        TsCaching.MarkAsUsed(this.assetPath, this.m_kItem.nVersion, this.m_kItem.bUseCustomCache);
                    }
                }
                else
                {
                    this.safeBundle = this.m_www.assetBundle;
                    if (null == this.safeBundle)
                    {
                        this._InternalOnly_ChangeStateErrorOrRetry("fail to access www.assetBundle.");
                        throw new NullReferenceException();
                    }
                    this.mainAsset = this.safeBundle.mainAsset;
                    TsFix.AudioSourceWarning(this.mainAsset as GameObject);
                    if (this.loadAll)
                    {
                        this.subBundles = this.safeBundle.LoadAll();
                        UnityEngine.Object[] subBundles = this.subBundles;
                        for (int i = 0; i < subBundles.Length; i++)
                        {
                            UnityEngine.Object @object = subBundles[i];
                            TsFix.AudioSourceWarning(@object as GameObject);
                        }
                    }
                }
                if (Option.EnableTrace)
                {
                    bool flag2 = false;
                    int  num   = -1;
                    if (this.m_kItem != null)
                    {
                        string url = Helper.FullURL(this.assetPath);
                        num   = this.m_kItem.nVersion;
                        flag2 = TsCaching.IsVersionCached(url, num, this.m_kItem.bUseCustomCache);
                    }
                    TsLog.Log("[TsBundle] download => success (AssetPath=\"{0}\", Stack=\"{1}\", Type={2}, Version={3}, RefCnt={4}, LoadFromCacheOrDownload={5}, Disposed={6}), Cached => {7}\r\nCallStack={8}", new object[]
                    {
                        this.assetPath,
                        this.stackName,
                        this.itemType,
                        num,
                        this.refCnt,
                        this.useLoadFromCacheOrDownload,
                        this.m_www == null,
                        (string.IsNullOrEmpty(this.anotherURL) || this.useLoadFromCacheOrDownload) ? flag2.ToString() : "(ignore)"
                    });
                }
            }
            catch (Exception ex)
            {
                TsLog.LogError("[TsBundle] Unity Assetbundle access exception! (Protocol=\"{0}\", AssetPath=\"{1}\", Stack=\"{2}\", Type={3}) => {4}\r\nCallStack={5}", new object[]
                {
                    Option.GetProtocolRootPath(this.m_protocol),
                    this.assetPath,
                    this.stackName,
                    this.itemType,
                    ex.ToString(),
                    this.RequestCallStack
                });
                this._InternalOnly_ChangeStateErrorOrRetry("Exception! Unity Assetbundle access violation!");
            }
            if (!this.useLoadFromCacheOrDownload && !this.isCacheHit && 0 < this.safeSize)
            {
                Holder.DbgAddWWWItemStat(this.assetPath, this.safeSize);
                if (WWWItem.OnIncreaseSizeOfDownload != null)
                {
                    WWWItem.OnIncreaseSizeOfDownload(this.safeSize);
                }
            }
        }
 public void _InternalOnly_ChangeStateRequest()
 {
     if (this.wiState != WWWItem.StateWI.UNLOADED)
     {
         if (this.wiState != WWWItem.StateWI.DESTROIED)
         {
             this.retryRequested = false;
             this.wiState        = WWWItem.StateWI.REQUESTED;
             string text;
             if (string.IsNullOrEmpty(this.anotherURL))
             {
                 if (Option.usePatchDir && this.m_protocol == Protocol.HTTP && this.m_kItem != null)
                 {
                     string protocolRootPath = Option.GetProtocolRootPath(this.m_protocol);
                     string format           = string.Empty;
                     if (protocolRootPath[protocolRootPath.Length - 1] == '/')
                     {
                         if (this.assetPath[0] == '/')
                         {
                             format = "{0}{1}{2}";
                         }
                         else
                         {
                             format = "{0}{1}/{2}";
                         }
                     }
                     else if (this.assetPath[0] == '/')
                     {
                         format = "{0}/{1}{2}";
                     }
                     else
                     {
                         format = "{0}/{1}/{2}";
                     }
                     text = string.Format(format, protocolRootPath, this.m_kItem.VersionDir, this.assetPath);
                 }
                 else
                 {
                     text = Option.GetProtocolRootPath(this.m_protocol) + this.assetPath;
                 }
             }
             else
             {
                 text = this.anotherURL;
             }
             if (this.m_protocol == Protocol.HTTP && 0 < this.retryCnt)
             {
                 if (text.Contains("?r="))
                 {
                     text = string.Format("{0}{1}", text, this.retryCnt);
                 }
                 else
                 {
                     text = string.Format("{0}?r={1}{2}", text, (int)(UnityEngine.Random.value * 1000000f), this.retryCnt);
                 }
                 TsLog.Log("[TsBundle] TsBundle:Retry = \"{0}\"", new object[]
                 {
                     text
                 });
             }
             if (Option.EnableTrace)
             {
                 TsLog.Log("[TsBundle] www loading (AssetPath=\"{0}\", Stack=\"{1}\", Type={2}, Size={3:#,###,###,###}, UnloadReserved={4}, RefCount={5} ) {6}", new object[]
                 {
                     this.assetPath,
                     this.stackName,
                     this.itemType,
                     (this.m_kItem != null) ? this.m_kItem.nFileSize : 0,
                     this.DebugUnloadReserved,
                     this.refCnt,
                     (this.m_kItem != null) ? ((!TsCaching.IsVersionCached(text, this.m_kItem.nVersion, this.m_kItem.bUseCustomCache)) ? "<<will download>>" : "<<Cached>>") : "<<not listed>>"
                 });
             }
             if (string.IsNullOrEmpty(this.anotherURL))
             {
                 UsingAssetRecorder.RecordFile(this.assetPath);
             }
             this._ReleaseLoadedAsset();
             if (this.useLoadFromCacheOrDownload)
             {
                 if (!this.inUndefinedStack)
                 {
                     this.m_www = Holder.CancelPreDownload(this.assetPath);
                 }
                 if (this.m_www == null)
                 {
                     this.m_www = TsCaching.LoadFromCacheOrDownload(text, this.m_kItem.nVersion, (long)this.m_kItem.nFileSize, this.m_kItem.bUseCustomCache, this);
                 }
                 if (!this.isCacheHit)
                 {
                     Holder.DbgAddWWWItemStat(this.assetPath, this.m_kItem.nFileSize);
                     if (0 < this.m_kItem.nFileSize && WWWItem.OnIncreaseSizeOfDownload != null)
                     {
                         WWWItem.OnIncreaseSizeOfDownload(this.m_kItem.nFileSize);
                     }
                 }
             }
             else
             {
                 Holder.DbgAddWWWItemStat(this.assetPath, 0);
                 this.m_www = new WWW(text);
             }
             this.retryCnt++;
             return;
         }
     }
     try
     {
         if (Option.EnableTrace)
         {
             TsLog.Log("[TsBundle] cannot request download, already unloaded bundle (AssetPath=\"{0}\", Stack=\"{1}\", Type={2}, SIze={3:#,###,###,###})\n\rCallStack={4}", new object[]
             {
                 this.assetPath,
                 this.stackName,
                 this.itemType,
                 (this.m_kItem != null) ? this.m_kItem.nFileSize : 0,
                 this.RequestCallStack
             });
         }
     }
     catch (Exception arg)
     {
         TsLog.Log("[TsBundle] " + arg, new object[0]);
     }
 }