Пример #1
0
            public void LoadPanelResAsync()
            {
                if (m_PanelState != ePanelState.UnInit)
                {
                    return;
                }

                m_PanelState = ePanelState.Loading;

                UIData data = UIDataTable.Get(m_UIID);

                if (data == null)
                {
                    return;
                }

                PrepareDynamicResource(data);

                m_ResLoader.Add2Load(data.fullPath, (state, res) =>
                {
                    if (!state)
                    {
                        return;
                    }

                    OnPanelResLoadSuccess((GameObject)res.asset);
                });

                m_ResLoader.LoadSync();
            }
Пример #2
0
        private IEnumerator Start()
        {
            yield return(new WaitForSeconds(2.0f));

            mResLoader.LoadAsync <AudioClip>("resources://coin", coinClip =>
            {
                Debug.Log(coinClip.name);

                Debug.Log(Time.time);
            });

            Debug.Log(Time.time);

            yield return(new WaitForSeconds(2.0f));

            mResLoader.LoadSync <AudioClip>("resources://home");

            yield return(new WaitForSeconds(2.0f));

            mResLoader.LoadSync <GameObject>("resources://HomePanel");

            mResLoader.LoadSync <AudioClip>("resources://Audio/coin");

            yield return(new WaitForSeconds(5.0f));

            mResLoader.ReleaseAll();
        }
Пример #3
0
        public GameObject LoadPanelPrefab(string panelName)
        {
#if COCOS_SUPPORT
            var retObj = mResLoader.LoadSync <GameObject>(string.Format("Resources/{0}", panelName));
            if (null != retObj)
            {
                return(retObj);
            }
            #endif

            return(mResLoader.LoadSync <GameObject>(panelName));
        }
Пример #4
0
        private void Start()
        {
            var coinClip = mResLoader.LoadSync <AudioClip>("resources://coin");

            var homeClip = mResLoader.LoadSync <AudioClip>("resources://home");

            var bgClip = mResLoader.LoadSync <AudioClip>("resources://coin");

            ///

            OtherFunction();
        }
Пример #5
0
            public GameObject LoadPanelPrefab(PanelSearchKeys panelSearchKeys)
            {
                if (panelSearchKeys.PanelType.IsNotNull() && panelSearchKeys.GameObjName.IsNullOrEmpty())
                {
                    return(mResLoader.LoadSync <GameObject>(panelSearchKeys.PanelType.Name));
                }

                if (panelSearchKeys.AssetBundleName.IsNotNullAndEmpty())
                {
                    return(mResLoader.LoadSync <GameObject>(panelSearchKeys.AssetBundleName, panelSearchKeys.GameObjName));
                }

                return(mResLoader.LoadSync <GameObject>(panelSearchKeys.GameObjName));
            }
Пример #6
0
        private UIRoot LoadUIRoot()
        {
            ResLoader loader = ResLoader.Allocate(null);

            loader.Add2Load(ProjectPathConfigTemp.UI_ROOT_PATH);
            loader.LoadSync();

            IRes res = ResMgr.Instance.GetRes(ProjectPathConfigTemp.UI_ROOT_PATH, false);

            if (res == null || res.asset == null)
            {
                return(null);
            }

            GameObject prefab = res.asset as GameObject;

            if (prefab == null)
            {
                return(null);
            }

            GameObject uiRoot = GameObject.Instantiate(prefab);

            loader.ReleaseAllRes();
            loader.Recycle2Cache();
            return(uiRoot.GetComponent <UIRoot>());
        }
Пример #7
0
        private static AppConfig LoadInstance()
        {
            if (m_ResLoader != null)
            {
                m_ResLoader.ReleaseAllRes();
            }

            if (m_ResLoader == null)
            {
                m_ResLoader = ResLoader.Allocate(null);
            }

            m_ResLoader.Add2Load(ProjectPathConfigTemp.APP_CONFIG_PATH);

            m_ResLoader.LoadSync();

            IRes res = ResMgr.Instance.GetRes(ProjectPathConfigTemp.APP_CONFIG_PATH, false);

            if (res != null)
            {
                s_Instance = res.asset as AppConfig;
            }

            return(s_Instance);
        }
Пример #8
0
        // Use this for initialization
        void Start()
        {
            mBundle = mResLoader.LoadSync <AssetBundle>("gameobject");

            var gameObj = mBundle.LoadAsset <GameObject>("GameObject");


            Instantiate(gameObj);
        }
Пример #9
0
        // Use this for initialization
        void Start()
        {
            var squareTexture = mResLoader.LoadSync <Texture2D>("square", "Square");

            Debug.Log(squareTexture.name);

//			mResLoader.LoadAsync<GameObject>("gameobject","GameObject",
//				gameObjPrefab => { Instantiate(gameObjPrefab); });
        }
Пример #10
0
        public static AssetBundleManifest LoadInstance()
        {
            ResLoader loader = ResLoader.Allocate();

            AssetBundleManifest manifest = loader.LoadSync(QFrameworkConfigData.ABMANIFEST_ASSET_NAME) as AssetBundleManifest;

            loader.UnloadImage(false);

            return(manifest);
        }
Пример #11
0
        public static AssetBundleManifest LoadInstance()
        {
            ResLoader loader = ResLoader.Allocate();

            AssetBundleManifest manifest = loader.LoadSync(ProjectPathConfigTemp.ABMANIFEST_ASSET_NAME) as AssetBundleManifest;

            loader.UnloadImage(false);

            return(manifest);
        }
Пример #12
0
        public override bool LoadSync()
        {
            State = ResState.Loading;

            var dependencyBundleNames = ResData.Instance.GetDirectDependencies(Name);

            foreach (var dependencyBundleName in dependencyBundleNames)
            {
                mResLoader.LoadSync <AssetBundle>(dependencyBundleName);
            }

            if (!ResMgr.IsSimulationModeLogic)
            {
                AssetBundle = AssetBundle.LoadFromFile(mPath);
            }

            State = ResState.Loaded;

            return(AssetBundle);
        }
Пример #13
0
        public override bool LoadSync()
        {
            State = ResState.Loading;

            var ownerBundle = mResLoader.LoadSync <AssetBundle>(mOwnerBundleName);

            if (ResMgr.IsSimulationModeLogic)
            {
#if UNITY_EDITOR
                var assetPaths = UnityEditor.AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(mOwnerBundleName, Name);
                Asset = UnityEditor.AssetDatabase.LoadAssetAtPath <Object>(assetPaths[0]);
#endif
            }
            else
            {
                Asset = ownerBundle.LoadAsset(Name);
            }

            State = ResState.Loaded;

            return(Asset);
        }
Пример #14
0
        public bool LoadABSceneFromSync(string sceneName, LoadSceneMode mode = LoadSceneMode.Single)
        {
            ResLoader nextLoader = ResLoader.Allocate();

            //提前加入可以起到缓存已经加载的资源的作用,防止释放后又加载的重复动作
            if (!AddSceneAB2Loader(sceneName, nextLoader))
            {
                return(false);
            }

            if (m_CurrentLoader != null)
            {
                m_CurrentLoader.ReleaseAllRes();
                m_CurrentLoader.Recycle2Cache();
                m_CurrentLoader = null;
            }

            m_CurrentLoader = nextLoader;

            m_CurrentLoader.LoadSync();

            try
            {
                SceneManager.LoadScene(sceneName, mode);
            }
            catch (Exception e)
            {
                Log.e("SceneManager LoadABSceneFromSync Failed! SceneName:" + sceneName);
                Log.e(e);
                UnloadSceneAssetBundle(sceneName);
                return(false);
            }

            UnloadSceneAssetBundle(sceneName);
            return(true);
        }
Пример #15
0
        /// <summary>
        /// 增加UI层
        /// </summary>
        public T CreateUI <T>(QUILevel level, QUIData initData = null) where T : QUIBehaviour
        {
            string behaviourName = GetUIBehaviourName <T> ();

            QUIBehaviour ui;

            if (mAllUI.TryGetValue(behaviourName, out ui))
            {
                Debug.LogWarning(behaviourName + ": already exist");
                //直接返回,不要再调一次Init(),Init()应该只能调用一次
                return(ui as T);
            }
            ResLoader resLoader = ResLoader.Allocate();

            GameObject prefab = resLoader.LoadSync(behaviourName) as GameObject;

            GameObject mUIGo = Instantiate(prefab);

            switch (level)
            {
            case QUILevel.Bg:
                mUIGo.transform.SetParent(mBgTrans);
                break;

            case QUILevel.Common:
                mUIGo.transform.SetParent(mCommonTrans);
                break;

            case QUILevel.PopUI:
                mUIGo.transform.SetParent(mPopUITrans);
                break;

            case QUILevel.Const:
                mUIGo.transform.SetParent(mConstTrans);
                break;

            case QUILevel.Toast:
                mUIGo.transform.SetParent(mToastTrans);
                break;

            case QUILevel.Forward:
                mUIGo.transform.SetParent(mForwardTrans);
                break;
            }

            var uiGoRectTrans = mUIGo.GetComponent <RectTransform> ();

            uiGoRectTrans.offsetMin          = Vector2.zero;
            uiGoRectTrans.offsetMax          = Vector2.zero;
            uiGoRectTrans.anchoredPosition3D = Vector3.zero;
            uiGoRectTrans.anchorMin          = Vector2.zero;
            uiGoRectTrans.anchorMax          = Vector2.one;

            mUIGo.transform.localScale = Vector3.one;


            mUIGo.gameObject.name = behaviourName;

            Debug.Log(behaviourName + " Load Success");

            ui = mUIGo.AddComponent <T>();
            mAllUI.Add(behaviourName, ui);
            ui.Init(resLoader, initData);

            return(ui as T);
        }
 public GameObject LoadPanelPrefab(string panelName)
 {
     return(mResLoader.LoadSync <GameObject>(panelName));
 }