Ejemplo n.º 1
0
        private void OnResourceLoaded(Resource res)
        {
            if (m_cResource != null)
            {
                m_cResource.Release();
            }
            m_cResource = res;
            m_cResource.Retain();
            UnityEngine.Object objPrefab = m_cResource.GetAsset(null);
            this.MainGO = GameObject.Instantiate(objPrefab) as GameObject;

            if (this.MainGO != null)
            {
                this.MainGO.transform.SetParent(ViewSys.Instance.Root2D.transform, false);
                this.MainGO.name = this.viewName;
            }

            this._subViews = this.BuildSubViews();
            if (this._subViews != null)
            {
                int count = this._subViews.Count;
                for (int i = 0; i < count; ++i)
                {
                    this._subViews[i].viewController = this;
                }
            }

            if (this.MainGO != null)
            {
                this.MainGO.SetActive(false);
            }
            OnResLoad();
        }
Ejemplo n.º 2
0
 private void OnResourceDone(Resource res)
 {
     if (res.isSucc)
     {
         List <ResourceHandlerStruct> succList;
         _succCallbacks.TryGetValue(res, out succList);
         _succCallbacks.Remove(res);
         if (succList != null)
         {
             while (succList.Count > 0)
             {
                 var callbackStruct = succList[0];
                 succList.RemoveAt(0);
                 callbackStruct.callback.Invoke(res, callbackStruct.path);
             }
         }
         res.Release();
     }
     else
     {
         //失败的话,将资源先移除掉
         if (res.refCount > 1)
         {
             CLog.LogError("DestroyResource[resPath=" + res.realPath + "],RefCount>1.");
         }
         else
         {
             _mapRes.Remove(res.realPath);
         }
         List <ResourceHandlerStruct> failList;
         _failCallbacks.TryGetValue(res, out failList);
         _failCallbacks.Remove(res);
         if (failList != null)
         {
             while (failList.Count > 0)
             {
                 var callbackStruct = failList[0];
                 failList.RemoveAt(0);
                 callbackStruct.callback.Invoke(res, callbackStruct.path);
             }
         }
         res.Release();
         if (res.refCount <= 0)
         {
             res.DestroyResource();
         }
     }
 }
Ejemplo n.º 3
0
        public void Clear(string path)
        {
            ResourceSys.Instance.RemoveListener(path, OnResLoad);
            m_dicCallback.Remove(path);
            Resource           resource = null;
            Queue <GameObject> queue    = null;

            foreach (var item in m_dicGO)
            {
                if (item.Key.path == path)
                {
                    resource = item.Key;
                    queue    = item.Value;
                    break;
                }
            }
            if (resource != null)
            {
                m_dicGO.Remove(resource);
                while (queue.Count > 0)
                {
                    GameObject.Destroy(queue.Dequeue());
                }
                resource.Release();
            }
        }
Ejemplo n.º 4
0
 public void RemoveWaitLoadingRes(Resource res)
 {
     if (_resLoader.RemoveWaitingLoadingRes(res))
     {
         RemoveAllListener(res);
         if (_mapRes.Remove(res.path))
         {
             res.Release();
         }
     }
 }
Ejemplo n.º 5
0
        private void OnResourceLoaded(Resource res, string path)
        {
            if (m_cResource != null)
            {
                m_cResource.Release();
            }
            m_cResource = res;
            m_cResource.Retain();
            UnityEngine.Object objPrefab = m_cResource.GetAsset(path);
            this.MainGO = GameObject.Instantiate(objPrefab) as GameObject;

            if (this.MainGO != null)
            {
                this.MainGO.transform.SetParent(ViewSys.Instance.Root2D.transform, false);
                this.MainGO.name = this.viewName;
            }

            this._subViews = this.BuildSubViews();
            if (this._subViews != null)
            {
                int count = this._subViews.Count;
                for (int i = 0; i < count; ++i)
                {
                    this._subViews[i].viewController = this;
                }
            }

            if (this.MainGO != null)
            {
                Canvas canvas = this.MainGO.AddComponentOnce <Canvas>();
                canvas.overrideSorting = true;
                this.MainGO.AddComponentOnce <UIViewMono>();
                canvas.sortingOrder = 0;
            }

            if (this.MainGO != null)
            {
                this.MainGO.SetActive(false);
            }
            OnResLoad();
        }