Beispiel #1
0
 private void ReadFileAsync(XFileReadAsync xfra)
 {
     XTableAsyncLoader.AddTableScript(xfra.Location, xfra.Reader.GetType());
     xfra.Data = new MemoryStream();
     if (!XSingleton <XResourceLoaderMgr> .singleton.ReadText(xfra.Location, xfra.Data as MemoryStream, false))
     {
         XResourceLoaderMgr.LoadErrorLog(xfra.Location);
         xfra.Data.Close();
         xfra.Data        = null;
         xfra.IsDone      = true;
         this.currentXfra = null;
         return;
     }
     ThreadPool.QueueUserWorkItem(delegate(object state)
     {
         try
         {
             if (!xfra.Reader.ReadFile(xfra.Data))
             {
                 XSingleton <XDebug> .singleton.AddErrorLog("in File: ", xfra.Location, xfra.Reader.error, null, null, null);
             }
             else
             {
                 xfra.IsDone = true;
             }
         }
         catch (Exception ex)
         {
             XSingleton <XDebug> .singleton.AddErrorLog(ex.Message, " in File: ", xfra.Location, xfra.Reader.error, null, null);
         }
         if (xfra.Data != null)
         {
             xfra.Data.Close();
             xfra.Data = null;
         }
         this.currentXfra = null;
     });
 }
Beispiel #2
0
        public void ResourceLoadCompleteCb(ResourceRequest loader)
        {
            this.complete = true;
            if (loader.asset == null)
            {
                XResourceLoaderMgr.LoadErrorLog(this.location);
                this.ReturnNull();
                return;
            }
            if (XSingleton <XResourceLoaderMgr> .singleton.useNewMgr)
            {
                XResourceLoaderMgr.UniteObjectInfo uniteObjectInfo;
                bool objectAsync = XSingleton <XResourceLoaderMgr> .singleton.GetObjectAsync(this.location, this.hash, loader.asset, null, this.isSharedRes, out uniteObjectInfo);

                if (uniteObjectInfo != null)
                {
                    int i     = 0;
                    int count = this.loadCbList.Count;
                    while (i < count)
                    {
                        LoadInfo loadInfo = this.loadCbList[i];
                        if (loadInfo.loadCb != null)
                        {
                            UnityEngine.Object @object = XSingleton <XResourceLoaderMgr> .singleton.GetObject(uniteObjectInfo, this.isSharedRes, loadInfo.usePool, objectAsync);

                            loadInfo.loadCb(@object, this.location, this.isSharedRes);
                        }
                        i++;
                    }
                    this.loadCbList.Clear();
                    return;
                }
            }
            else
            {
                XSingleton <XResourceLoaderMgr> .singleton.AddAssetInPool(loader.asset, this.hash, null);

                int j      = 0;
                int count2 = this.loadCbList.Count;
                while (j < count2)
                {
                    LoadInfo loadInfo2 = this.loadCbList[j];
                    if (loadInfo2.loadCb != null)
                    {
                        if (this.isSharedRes)
                        {
                            this.GetSharedResourceCb(loadInfo2.loadCb, null);
                        }
                        else
                        {
                            UnityEngine.Object obj = null;
                            if (loadInfo2.usePool && XSingleton <XResourceLoaderMgr> .singleton.GetInObjectPool(ref obj, this.hash))
                            {
                                loadInfo2.loadCb(obj, this.location, this.isSharedRes);
                            }
                            else
                            {
                                this.CreateFromPrefabCb(loadInfo2.loadCb, null);
                            }
                        }
                    }
                    j++;
                }
                this.loadCbList.Clear();
            }
        }