private void OnDestroy() { if (!MonoSingleton.isApplicationQuit) { if (m_ResLoader != null) { m_ResLoader.Recycle2Cache(); m_ResLoader = null; } } }
public void LoadBuildInSceneAsync(string sceneName, Action <string, bool> loadCallback = null, LoadSceneMode mode = LoadSceneMode.Single) { if (m_CurrentLoader != null) { m_CurrentLoader.ReleaseAllRes(); m_CurrentLoader.Recycle2Cache(); m_CurrentLoader = null; } StartCoroutine(LoadSceneAsync(sceneName, loadCallback, mode, false)); }
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(); }
//收集预加载资源 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); }
private bool AddSceneAB2Loader(string sceneName, ResLoader loader) { string abName = GetSceneAssetBundleName(sceneName); if (string.IsNullOrEmpty(abName)) { return(false); } loader.Add2Load(abName); return(true); }
protected void Init() { if (m_HasInit) { return; } m_HasInit = true; m_ResLoader = ResLoader.Allocate("RemoteConfig"); m_CheckFuns = new Action[] { UpdateConfigFile, }; }
private void CleanPreRes() { if (m_ResLoader != null) { m_ResLoader.Recycle2Cache(); m_ResLoader = null; } if (m_TimerID > 0) { Timer.S.Cancel(m_TimerID); m_TimerID = 0; return; } }
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 static Sprite FindSprite(ResLoader loader, string assetName, string spriteName) { Sprite result = null; result = loader.LoadSync(spriteName) as Sprite; if (result == null) { var data = loader.LoadSync(assetName) as SpritesData; if (data != null) { m_GlobalSprHandler.SetData(new SpritesData[] { data }); return(m_GlobalSprHandler.FindSprite(spriteName) as Sprite); } } return(result); }
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(); } }
protected void OnMeshLoadResult(bool result, IRes res) { if (result) { MeshHolder holder = res.asset as MeshHolder; if (holder != null) { mesh = holder.Find(m_MeshName); } } if (m_PreLoader != null) { m_PreLoader.Recycle2Cache(); m_PreLoader = null; } }
private void CleanResources() { if (m_OnStopListener != null) { m_OnStopListener(m_ID); } UnRegisterActiveAudioUnit(this); m_Name = null; m_PlayCount = 0; m_IsPause = false; m_OnFinishListener = null; m_OnStopListener = null; m_LeftDelayTime = -1; m_CustomEventID = -1; if (m_TimeItemID > 0) { Timer.S.Cancel(m_TimeItemID); m_TimeItemID = -1; } if (m_Source != null) { if (m_Source.clip == m_AudioClip) { if (m_Source.enabled) { m_Source.Stop(); } m_Source.clip = null; } m_Source.volume = 1.0f; m_Source.pitch = 1.0f; } m_AudioClip = null; if (m_Loader != null) { m_Loader.Recycle2Cache(); m_Loader = null; } }
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_CurrentMaster); 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(); }
protected override void OnClose() { if (m_Action != null) { m_Action.OnTransitionDestroy(); } m_OpenParam = null; m_Action = null; m_NextPanel = null; if (m_NextPanelResLoader != null) { m_NextPanelResLoader.Recycle2Cache(); m_NextPanelResLoader = null; } }
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); }
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(); } }
public bool LoadBuildInSceneSync(string sceneName, LoadSceneMode mode = LoadSceneMode.Single) { if (m_CurrentLoader != null) { m_CurrentLoader.ReleaseAllRes(); m_CurrentLoader.Recycle2Cache(); m_CurrentLoader = null; } try { SceneManager.LoadScene(sceneName, mode); } catch (Exception e) { Log.e("SceneManager LoadBuildInSceneSysn Failed! SceneName:" + sceneName); Log.e(e); return(false); } return(true); }
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); }
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); } m_Loader.LoadAsync(OnPackageUpdateFinish); }
private static SDKConfig LoadInstance() { ResLoader loader = ResLoader.Allocate("AppConfig", null); UnityEngine.Object obj = loader.LoadSync("Resources/Config/SDKConfig"); if (obj == null) { Log.e("Not Find SDK Config, Will Use Default App Config."); loader.Recycle2Cache(); return(null); } //Log.i("Success Load SDK Config."); s_Instance = obj as SDKConfig; SDKConfig newAB = GameObject.Instantiate(s_Instance); s_Instance = newAB; loader.Recycle2Cache(); return(s_Instance); }
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); }
public void OnCacheReset() { m_Panel = null; m_NextMaster = -1; m_PanelID = -1; m_UIID = -1; m_SortIndex = -1; m_PanelState = ePanelState.UnInit; m_OpenListeners = null; m_CustomVisibleFlag = true; m_ResLoader.Recycle2Cache(); m_ResLoader = null; if (m_PageWrapList != null) { m_PageWrapList.Clear(); } if (m_OpenInfoList != null) { m_OpenInfoList.Clear(); } }
private void LoadNextPanelRes() { if (m_NextPanelResLoader != null) { m_NextPanelResLoader.ReleaseAllRes(); } else { m_NextPanelResLoader = ResLoader.Allocate("SwitchAnimPanel"); } 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 SetMaterial(string materialName) { ResLoader loader = ResLoader.Allocate("Temp"); m_Render.material = loader.LoadSync(materialName) as Material; }
public static void LoadSpinAnimSkeleton(Spine.Unity.SkeletonAnimation anim, Qarth.ResLoader loader, string asset) { Spine.Unity.SkeletonDataAsset data = loader.LoadSync(asset) as Spine.Unity.SkeletonDataAsset; anim.skeletonDataAsset = data; anim.Initialize(true); }
public override void OnSingletonInit() { m_Loader = ResLoader.Allocate("ResHolder"); }