public void TestResLoader() { m_Loader = ResLoader.Allocate(); m_Loader.Add2Load("Bench_A"); m_Loader.LoadAsync(ResLoaderCallback); //GameObject go = m_Loader.LoadSync("Bench_A") as GameObject; //GameObject.Instantiate(go); //回收资源 //m_Loader.Recycle2Cache(); }
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(); 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(); } }
private static SDKConfig LoadInstance() { ResLoader loader = ResLoader.Allocate(); UnityEngine.Object obj = loader.LoadSync("Resources/Config/SDKConfig"); if (obj == null) { loader.Recycle2Cache(); return(null); } instance = obj as SDKConfig; SDKConfig newAB = GameObject.Instantiate(instance); instance = newAB; loader.Recycle2Cache(); return(instance); }
private static AppConfig LoadInstance() { ResLoader loader = ResLoader.Allocate(); UnityEngine.Object obj = loader.LoadSync("Resources/Config/AppConfig"); if (obj == null) { loader.Recycle2Cache(); return(null); } instance = obj as AppConfig; // // AppConfig newAB = GameObject.Instantiate(instance); // // instance = newAB; //loader.Recycle2Cache(); //简易写法 //instance = Resources.Load<AppConfig>("Config/AppConfig"); return(instance); }
public override void OnSingletonInit() { m_UILoader = ResLoader.Allocate(); m_UIRoot = GameObject.FindObjectOfType <UIRoot>(); }