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); }
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(); } }
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>()); }
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(); }
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 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); }
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 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 SetMaterial(string materialName) { ResLoader loader = ResLoader.Allocate("Temp"); m_Render.material = loader.LoadSync(materialName) as Material; }