Example #1
0
        private void LoadNextPanelRes()
        {
            if (m_NextPanelResLoader != null)
            {
                m_NextPanelResLoader.ReleaseAllRes();
            }
            else
            {
                m_NextPanelResLoader = ResLoader.Allocate("SwitchAnimPanel");
            }

            if (m_OpenParam.nextPanelUIID < 0)
            {
                OnNextPanelResLoadFinish();
            }

            UIData data = UIDataTable.Get(m_OpenParam.nextPanelUIID);

            if (data == null)
            {
                return;
            }

            UIMgr.CollectDynamicResource(data, m_NextPanelResLoader, m_OpenParam.args);

            m_NextPanelResLoader.Add2Load(data.fullPath);

            m_NextPanelResLoader.LoadAsync(OnNextPanelResLoadFinish);
        }
Example #2
0
        private static AppConfig LoadInstance()
        {
            ResLoader loader = ResLoader.Allocate("AppConfig", null);

            UnityEngine.Object obj = loader.LoadSync(ProjectPathConfig.appConfigPath);
            if (obj == null)
            {
                Log.w("Not Find App Config, Will Use Default App Config.");
                loader.ReleaseAllRes();
                obj = loader.LoadSync(ProjectPathConfig.DEFAULT_APP_CONFIG_PATH);
                if (obj == null)
                {
                    Log.e("Not Find Default App Config File!");
                    loader.Recycle2Cache();
                    loader = null;
                    return(null);
                }
            }

            //Log.i("Success Load App Config.");
            s_Instance = obj as AppConfig;

            AppConfig newAB = GameObject.Instantiate(s_Instance);

            s_Instance = newAB;

            loader.Recycle2Cache();

            return(s_Instance);
        }
Example #3
0
            public void LoadPageResAsync(int uiID, Transform parent, bool singleton, Action <AbstractPage> listener)
            {
                UIData data = UIDataTable.Get(uiID);

                if (data == null)
                {
                    Log.e("Failed to load UI, Not Find UIData For:" + uiID);
                    return;
                }

                if (singleton)
                {
                    if (m_PageWrapList == null)
                    {
                        m_PageWrapList = new List <PageWrap>();
                    }

                    PageWrap wrap = FindPageWrap(uiID);

                    if (wrap != null)
                    {
                        wrap.AddListener(listener);
                        return;
                    }
                    else
                    {
                        wrap = new PageWrap(uiID);
                        wrap.AddListener(listener);

                        m_PageWrapList.Add(wrap);
                    }
                }

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

                CollectDynamicResource(data, m_ResLoader);

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

                    OnPageResLoadSuccess(uiID, parent, (GameObject)res.asset, singleton, listener);
                });

                m_ResLoader.LoadSync();
            }
Example #4
0
        public void PrepareTransition()
        {
            if (m_ResLoader == null)
            {
                m_ResLoader = ResLoader.Allocate("FadeInOutAnim");
            }
            else
            {
                m_ResLoader.ReleaseAllRes();
            }

            m_ResLoader.Add2Load("SwitchAnimShaderAnim", OnResLoadFinish);

            m_ResLoader.LoadAsync();
        }
Example #5
0
            public void SetAudio(GameObject root, string name, bool loop, bool isEnable)
            {
                if (string.IsNullOrEmpty(name))
                {
                    return;
                }

                if (m_Name == name)
                {
                    return;
                }

                if (m_Source == null)
                {
                    m_Source = root.AddComponent <AudioSource>();
                    if (!isEnable)
                    {
                        m_Source.enabled = isEnable;
                    }
                }

                //防止卸载后立马加载的情况
                ResLoader preLoader = m_Loader;

                m_Loader = null;
                CleanResources();

                RegisterActiveAudioUnit(this);

                m_Loader = ResLoader.Allocate("AudioUnit");

                m_IsLoop = loop;
                m_Name   = name;

                m_Loader.Add2Load(name, OnResLoadFinish);

                if (preLoader != null)
                {
                    preLoader.Recycle2Cache();
                    preLoader = null;
                }

                if (m_Loader != null)
                {
                    m_Loader.LoadAsync();
                }
            }
Example #6
0
            public void LoadPanelResAsync()
            {
                if (m_PanelState != ePanelState.UnInit)
                {
                    return;
                }

                m_PanelState = ePanelState.Loading;

                UIData data = UIDataTable.Get(m_UIID);

                if (data == null)
                {
                    return;
                }

                OpenParam info = GetOpenInfo(m_NextMaster);

                object[] args = null;

                if (info != null)
                {
                    args = info.Args;
                }

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

                CollectDynamicResource(data, m_ResLoader, args);

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

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

                m_ResLoader.LoadSync();
            }
Example #7
0
        public void Load(string sprite)
        {
            if (m_SpriteRenderer == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(sprite))
            {
                return;
            }

            if (m_Loader != null)
            {
                m_Loader.ReleaseAllRes();
            }
            else
            {
                m_Loader = ResLoader.Allocate("AsyncSpriteRenderer");
            }

            m_SpriteName = sprite;

            m_Loader.Add2Load(sprite, (result, res) =>
            {
                if (result)
                {
                    m_SpriteRenderer.sprite = res.asset as Sprite;
                }
            });

            if (m_IsAsync)
            {
                m_Loader.LoadAsync();
            }
            else
            {
                m_Loader.LoadSync();
            }
        }
Example #8
0
        public Sprite FindSprite(string spriteName, bool global = false)
        {
            Sprite result = null;

            if (m_SpritesData == null || m_SpritesData.Length == 0)
            {
            }
            else
            {
                if (m_SpritesHandler == null)
                {
                    m_SpritesHandler = new SpritesHandler();
                    m_SpritesHandler.SetData(m_SpritesData);
                }

                result = m_SpritesHandler.FindSprite(spriteName);
            }

            if (result == null)
            {
                result = FindSpriteFromParent(spriteName, global);
            }

            if (result == null && global)
            {
                if (m_GlobalResLoader == null)
                {
                    m_GlobalResLoader = ResLoader.Allocate("AbstractPage");
                }

                result = m_GlobalResLoader.LoadSync(spriteName) as Sprite;
            }

            if (result == null)
            {
                Log.w("Not Find Sprite:" + spriteName);
            }

            return(result);
        }
Example #9
0
        private void InnerStartUpdate(List <ABUnit> updateList)
        {
            if (updateList == null || updateList.Count == 0)
            {
                return;
            }

            if (m_Loader != null)
            {
                Log.w("Package Handler is Working.");
                return;
            }

            m_Loader = ResLoader.Allocate("ResPackageHolder");

            if (m_UpdateUnitMap == null)
            {
                m_UpdateUnitMap = new Dictionary <string, ABUnit>();
            }
            else
            {
                m_UpdateUnitMap.Clear();
            }

            for (int i = 0; i < updateList.Count; ++i)
            {
                string resName = AssetName2ResName(updateList[i].abName);

                m_UpdateUnitMap.Add(resName, updateList[i]);

                m_Loader.Add2Load(resName, OnResUpdateFinish);
                HotUpdateRes res          = ResMgr.S.GetRes <HotUpdateRes>(resName);
                string       relativePath = m_Package.GetABLocalRelativePath(updateList[i].abName);
                string       fullPath     = FilePath.persistentDataPath4Res + relativePath;
                res.SetUpdateInfo(fullPath, m_Package.GetAssetUrl(relativePath), updateList[i].fileSize, null);
            }

            m_Loader.LoadAsync(OnPackageUpdateFinish);
        }
Example #10
0
        private void UpdateSprites()
        {
            CleanPreRes();
            if (targetImage == null || m_SpritesNames == null || m_SpritesNames.Length == 0)
            {
                return;
            }

            m_ResLoader = ResLoader.Allocate();
            m_ResLoader.Add2Load(m_SpritesNames);

            m_ResLoader.LoadSync();
            m_SpritesArray = new Sprite[m_SpritesNames.Length];

            for (int i = 0; i < m_SpritesNames.Length; ++i)
            {
                m_SpritesArray[i] = ResMgr.S.GetAsset <Sprite>(m_SpritesNames[i]);
            }

            OnTimeReach(0);
            m_TimerID = Timer.S.Post2Scale(OnTimeReach, m_Duration, -1);
        }
Example #11
0
        public bool LoadABSceneFromSync(string sceneName, LoadSceneMode mode = LoadSceneMode.Single)
        {
            ResLoader nextLoader = ResLoader.Allocate("SceneMgr");

            //提前加入可以起到缓存已经加载的资源的作用,防止释放后又加载的重复动作
            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);
        }
Example #12
0
        public void SetMaterial(string materialName)
        {
            ResLoader loader = ResLoader.Allocate("Temp");

            m_Render.material = loader.LoadSync(materialName) as Material;
        }
Example #13
0
 public override void OnSingletonInit()
 {
     m_Loader = ResLoader.Allocate("ResHolder");
 }