Exemple #1
0
        public void LoadTexture(string path)
        {
            if (m_RawImage == null)
            {
                return;
            }

            m_RawImage.texture = null;
            if (m_AutoHide)
            {
                m_RawImage.enabled = false;
            }
            if (m_ResLoader != null)
            {
                m_ResLoader.ReleaseAllRes();
            }

            m_TexturePath = path;

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

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

            m_ResLoader.Add2Load(m_TexturePath, OnResLoadFinish);
            m_ResLoader.LoadAsync();
        }
Exemple #2
0
        protected void LoadMesh()
        {
            m_MeshHolder = null;

            ResLoader loader = ResLoader.Allocate(null);

            loader.Add2Load(m_MeshHolderName, OnMeshLoadResult);

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

            m_PreLoader = m_Loader;

            m_Loader = loader;

            if (m_AsyncLoad)
            {
                m_Loader.LoadAsync();
            }
            else
            {
                m_Loader.LoadSync();
            }
        }
Exemple #3
0
        public void LoadABSceneAsync(string sceneName, Action <string, bool> loadCallback = null, LoadSceneMode mode = LoadSceneMode.Single)
        {
            ResLoader nextLoader = ResLoader.Allocate("SceneMgr");

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

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

            m_CurrentLoader = nextLoader;

            m_CurrentLoader.LoadAsync(() =>
            {
                StartCoroutine(LoadSceneAsync(sceneName, loadCallback, mode, true));
            });
        }
Exemple #4
0
        public void DownloadPackage(Action <ResPackageHandler> callback)
        {
            if (m_Loader != null)
            {
                Log.w("Package Handler is Working.");
                return;
            }

            m_Loader = ResLoader.Allocate("ResPackageHolder");

            m_DownloadListener = callback;
            string resName = AssetName2ResName(m_Package.packageName);

            m_Loader.Add2Load(resName, OnPackageDownloadFinish);

            HotUpdateRes hotUpdateRes = ResMgr.S.GetRes <HotUpdateRes>(resName);

            string fullPath = FilePath.persistentDownloadCachePath + m_Package.relativeLocalParentFolder + m_Package.zipFileName;

            hotUpdateRes.SetUpdateInfo(fullPath, m_Package.zipUrl, 10000, null);
            if (m_Loader != null)
            {
                m_Loader.LoadAsync();
            }
        }
Exemple #5
0
        public void CheckUpdateList(Action <ResPackageHandler> callBack)
        {
            if (m_Loader != null)
            {
                Log.w("Package Handler is Working.");
                return;
            }

            ApplyUpdateRecord();

            m_Loader = ResLoader.Allocate("ResPackageHolder");

            m_CheckListener = callBack;
            string resName = AssetName2ResName(m_Package.configFile);

            m_Loader.Add2Load(resName, OnRemoteABConfigDownloadFinish);

            HotUpdateRes hotUpdateRes = ResMgr.S.GetRes <HotUpdateRes>(resName);

            string fullPath = FilePath.persistentDownloadCachePath + m_Package.configFile;

            hotUpdateRes.SetUpdateInfo(fullPath, m_Package.GetAssetUrl(m_Package.configFile), 1000, null);

            if (m_Loader != null)
            {
                m_Loader.LoadAsync();
            }
        }
Exemple #6
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);
        }
Exemple #7
0
        public void LoadAllShader(string[] shaders)
        {
            if (shaders == null || shaders.Length == 0)
            {
                return;
            }

            for (int i = 0; i < shaders.Length; ++i)
            {
                m_Loader.Add2Load(shaders[i], OnShaderLoadFinish);
            }

            m_Loader.LoadAsync();
        }
Exemple #8
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();
        }
Exemple #9
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();
                }
            }
Exemple #10
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();
            }
        }
Exemple #11
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);
        }