//收集预加载资源 public static void CollectDynamicResource(UIData data, ResLoader loader, params object[] args) { if (data == null || data.panelClassType == null) { return; } //TimeDebugger timer = new TimeDebugger("PrepareDynamicResource"); //timer.Begin("P1"); var methodInfo = data.panelClassType.GetMethod("PrepareDynamicResource", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); //timer.End(); if (methodInfo == null) { //timer.Dump(-1); return; } object[] paramWrap = new object[1]; paramWrap[0] = args; //timer.Begin("P2"); object result = null; try { result = methodInfo.Invoke(null, paramWrap); } catch (Exception e) { result = null; Log.e(e); } if (result == null) { return; } if (result is List <string> ) { loader.Add2Load((List <string>)result); } else if (result is string) { loader.Add2Load((string)result); } //timer.End(); //timer.Dump(-1); }
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(); } }
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(); }
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(); } }
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(); } }
private UIRoot LoadUIRoot() { ResLoader loader = ResLoader.Allocate("UIMgr", null); loader.Add2Load(ProjectPathConfig.uiRootPath); loader.LoadSync(); IRes res = ResMgr.S.GetRes(ProjectPathConfig.uiRootPath, false); if (res == null || res.asset == null) { loader.Recycle2Cache(); return(null); } GameObject prefab = res.asset as GameObject; if (prefab == null) { loader.Recycle2Cache(); return(null); } GameObject uiRoot = GameObject.Instantiate(prefab); loader.Recycle2Cache(); return(uiRoot.GetComponent <UIRoot>()); }
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); }
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(); }
private bool AddSceneAB2Loader(string sceneName, ResLoader loader) { string abName = GetSceneAssetBundleName(sceneName); if (string.IsNullOrEmpty(abName)) { return(false); } loader.Add2Load(abName); return(true); }
public void PrepareTransition() { if (m_ResLoader == null) { m_ResLoader = ResLoader.Allocate("FadeInOutAnim"); } else { m_ResLoader.ReleaseAllRes(); } m_ResLoader.Add2Load("SwitchAnimShaderAnim", OnResLoadFinish); m_ResLoader.LoadAsync(); }
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(); } }
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(); } }
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); }
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); }
public void AddRes(string res) { m_Loader.Add2Load(res); }