Esempio n. 1
0
        private GameObject GetGameObject(Resource res)
        {
            UnityEngine.Object prefab = res.GetAsset(res.path);
            GameObject         go     = (GameObject)GameObject.Instantiate(prefab);

            return(go);
        }
Esempio n. 2
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();
        }
 private void OnResLoadCache(Resource res, string path)
 {
     if (res.isSucc)
     {
         ResourceObjectQueue resQueue = m_dicGO[path];
         resQueue.prefab = res.GetAsset(path);
         resQueue.isDone = true;
         List <CacheCallbackStruct> lstCallbackStruct = null;
         if (m_dicCacheCallback.TryGetValue(path, out lstCallbackStruct))
         {
             while (lstCallbackStruct.Count > 0)
             {
                 var callbackStruct = lstCallbackStruct[0];
                 lstCallbackStruct.RemoveAt(0);
                 if (!callbackStruct.isPrefab)
                 {
                     for (int i = 0; i < callbackStruct.count; i++)
                     {
                         var go = GetGameObject(resQueue.prefab, path);
                         SaveObject(path, go);
                     }
                 }
                 callbackStruct.callback.Invoke(path);
             }
         }
     }
     else
     {
         CLog.LogError("加载GameObject资源" + path + "失败");
     }
 }
Esempio n. 4
0
        public static GameObject GetGameObject(Resource res, string name)
        {
            var prefab = (GameObject)res.GetAsset(name);

            if (prefab != null)
            {
                return(GameObject.Instantiate(prefab));
            }
            return(null);
        }
Esempio n. 5
0
 private void OnLoadManifest(Resource res, string path)
 {
     if (res.isSucc)
     {
         m_cManifest = (AssetBundleManifest)res.GetAsset(null);
     }
     else
     {
         CLog.LogError("AssetBundleFile文件初始化失败!");
     }
     if (m_cCallback != null)
     {
         var callback = m_cCallback;
         m_cCallback = null;
         callback.Invoke(res.isSucc);
     }
 }
Esempio n. 6
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();
        }