Exemplo n.º 1
0
        public URLReqImpl()
        {
            bool flag = URLReqImpl.m_loader == null;

            if (flag)
            {
                URLReqImpl.m_loaderObj = new GameObject();
                URLReqImpl.m_loader    = URLReqImpl.m_loaderObj.AddComponent <LoaderBehavior>();
            }
            this.m_url = this.url;
        }
Exemplo n.º 2
0
        private void Update()
        {
            bool flag = this.m_loadingJobs < LoaderBehavior.MAX_LOADJOBS && this.m_jobs.Count > 0;

            if (flag)
            {
                LoaderJob value = this.m_jobs.First.Value;
                this.m_jobs.RemoveFirst();
                this.load(value.url, value.method, value.dataFmt, value.paras, value.onFin, value.onProg, value.onFail);
            }
            bool flag2 = LoaderBehavior.ms_LoadingProCount > 0;

            if (flag2)
            {
                LoaderBehavior.ms_NoLoadingCount = LoaderBehavior.ALL_LOADING_CALLBACK_W;
            }
            else
            {
                bool flag3 = LoaderBehavior.ms_NoLoadingCount > 0;
                if (flag3)
                {
                    LoaderBehavior.ms_NoLoadingCount--;
                }
                else
                {
                    bool flag4 = LoaderBehavior.ms_AllLoadedFin != null;
                    if (flag4)
                    {
                        LoaderBehavior.ms_AllLoadedFin();
                        LoaderBehavior.ms_AllLoadedFin   = null;
                        LoaderBehavior.ms_NoLoadingCount = LoaderBehavior.ALL_LOADING_CALLBACK_W;
                    }
                    LoaderBehavior.ms_HasAllLoaded = true;
                }
            }
        }
Exemplo n.º 3
0
        protected IEnumerator _loadRes(string url, string method, string dataFmt, string paras, bool unique, Action <object> onFin, Action <float> onProg = null, Action <string> onFail = null)
        {
            bool flag = dataFmt == "assetbundle";

            if (flag)
            {
                this.m_loadingJobs++;
            }
            if (unique)
            {
                string item = url.Substring(url.LastIndexOf('/') + 1);
                this.m_uniJobs.Add(item);
                item = null;
            }
            string message = LoaderBehavior._getStreamingFilePath(url, dataFmt);

            url = "file:///" + LoaderBehavior.DATA_PATH + "OutAssets/" + url;
            Debug.Log(message);
            message = null;
            bool flag2 = paras != null && paras.Length > 0;

            if (flag2)
            {
                url = url + "?" + paras;
            }
            WWW wWW = new WWW(url);

            LoaderBehavior.ms_LoadingProCount++;
            LoaderBehavior.ms_HasAllLoaded = false;
            yield return(this._evalWWW(wWW, onProg, 0f, 0.3f));

            bool flag3 = wWW.error != null;

            if (flag3)
            {
                Debug.Log("fail: " + url + " : " + wWW.error);
                bool flag4 = onFail != null;
                if (flag4)
                {
                    onFail(wWW.error);
                }
            }
            else
            {
                bool flag5 = onFin != null;
                if (flag5)
                {
                    bool flag6 = dataFmt == "binary";
                    if (flag6)
                    {
                        onFin(wWW.bytes);
                    }
                    else
                    {
                        bool flag7 = dataFmt == "text";
                        if (flag7)
                        {
                            onFin(wWW.text);
                        }
                        else
                        {
                            bool flag8 = dataFmt == "assetbundle";
                            if (flag8)
                            {
                                AssetBundle assetBundle = null;
                                while (assetBundle == null)
                                {
                                    try
                                    {
                                        assetBundle = wWW.assetBundle;
                                    }
                                    catch (Exception ex2)
                                    {
                                        Exception ex = ex2;
                                        Debug.Log("URL Error " + ex.Message);
                                    }
                                    bool flag9 = assetBundle == null;
                                    if (flag9)
                                    {
                                        yield return(new WaitForSeconds(1f));
                                    }
                                }
                                AssetBundleRequest assetBundleRequest = null;
                                bool flag10 = true;
                                bool flag11 = url.IndexOf(".pic") >= 0;
                                if (flag11)
                                {
                                    UnityEngine.Object @object = assetBundle.Load(LoaderBehavior._getAssetBundleName(url), typeof(Sprite));
                                    bool flag12 = @object != null;
                                    if (flag12)
                                    {
                                        onFin(@object);
                                    }
                                    else
                                    {
                                        bool flag13 = onFail != null;
                                        if (flag13)
                                        {
                                            onFail("AssebBundle.Load Sprite return null!");
                                        }
                                    }
                                    @object = null;
                                }
                                else
                                {
                                    bool flag14 = url.IndexOf(".anipic") >= 0;
                                    if (flag14)
                                    {
                                        UnityEngine.Object[] array = assetBundle.LoadAll(typeof(Sprite));
                                        bool flag15 = array != null;
                                        if (flag15)
                                        {
                                            onFin(array);
                                        }
                                        else
                                        {
                                            bool flag16 = onFail != null;
                                            if (flag16)
                                            {
                                                onFail("AssebBundle.LoadAll Sprite return null!");
                                            }
                                        }
                                        array = null;
                                    }
                                    else
                                    {
                                        bool flag17 = url.IndexOf(".unity") >= 0;
                                        if (flag17)
                                        {
                                            onFin(assetBundle);
                                            flag10 = false;
                                        }
                                        else
                                        {
                                            bool flag18 = url.IndexOf(".anim") >= 0;
                                            if (flag18)
                                            {
                                                assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(AnimationClip));
                                            }
                                            else
                                            {
                                                bool flag19 = url.IndexOf(".lmp") >= 0;
                                                if (flag19)
                                                {
                                                    assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(Texture));
                                                }
                                                else
                                                {
                                                    bool flag20 = url.IndexOf(".lpb") >= 0;
                                                    if (flag20)
                                                    {
                                                        assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(LightProbes));
                                                    }
                                                    else
                                                    {
                                                        bool flag21 = url.IndexOf(".snd") >= 0;
                                                        if (flag21)
                                                        {
                                                            assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(AudioClip));
                                                        }
                                                        else
                                                        {
                                                            assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(GameObject));
                                                        }
                                                    }
                                                }
                                            }
                                            yield return(this._evalAssetBundleReq(assetBundleRequest, onProg, 0.3f, 0.7f));

                                            onFin(assetBundleRequest.asset);
                                        }
                                    }
                                }
                                bool flag22 = flag10;
                                if (flag22)
                                {
                                    assetBundle.Unload(false);
                                }
                                assetBundle        = null;
                                assetBundleRequest = null;
                            }
                        }
                    }
                }
            }
            wWW.Dispose();
            bool flag23 = dataFmt == "assetbundle";

            if (flag23)
            {
                this.m_loadingJobs--;
            }
            if (unique)
            {
                string item2 = url.Substring(url.LastIndexOf('/') + 1);
                this.m_uniJobs.Remove(item2);
                item2 = null;
            }
            LoaderBehavior.ms_LoadingProCount--;
            yield break;
        }