public bool UpdateState() { bool handle = false; if (m_status == AssetLoadStatus.Loaded) { m_status = AssetLoadStatus.Finished; if (m_refBundle == null) { OnAssetLoaded(null); return(handle); } UnityEngine.Object obj = m_refBundle.LoadAsset(AssetCache.AssetNameToBundleAssetName(info.name, info.extName)); if (obj == null) { OnAssetLoaded(null); return(handle); } handle = true; AssetCache cache = new AssetCache(name, info, obj); AssetsMgr.GetInst().AddAssetCache(name, cache); OnAssetLoaded(cache); } return(handle); }
public static IEnumerator PreLoadAsyc(string[] resList) { counter = 0; preLoadItems.Clear(); for (int i = 0; i < resList.Length; i++) { PreloadItem item = new PreloadItem(); item.name = resList[i]; item.onAssetLoaded = OnAssetLoaded; preLoadItems.Add(item); AssetsMgr.GetInst().LoadAssetAsync(item.name, item.OnAssetLoaded); } bool bAllFinished = false; while (bAllFinished == false) { if (counter == preLoadItems.Count) { bAllFinished = true; break; } else { yield return(counter); } } }
public static AssetsMgr GetInst() { if (mgr == null) { mgr = new AssetsMgr(); } return(mgr); }
public static void LoadAssetAync(string name, Action <string, UnityEngine.Object> callback) { AssetAyncLoaderProxy proxy = new AssetAyncLoaderProxy(); proxy.callback = callback; proxyList.Add(proxy); AssetsMgr.GetInst().LoadAssetAsync(name, proxy.OnAssetLoaded); }
public static UnityEngine.Object LoadAssetSync(string name) { AssetCache asset = AssetsMgr.GetInst().LoadAssetSync(name); if (asset == null) { return(null); } return(asset.GetAsset()); }
public override void OnEnter(Status oldStatus) { AssetsMgr.GetInst().Init(); LogUtils.Log("enter game status!"); //sync //UnityEngine.Object obj = AssetsUtils.LoadAssetSync("character/models/human/1210001/1210001_2"); //GameObject o = GameObject.Instantiate(obj) as GameObject; //async AssetsUtils.LoadAssetAync("character/models/human/1230008/1230008_1", OnAssetLoaded); }
public override void OnExit(Status newStatus) { AssetsMgr.GetInst().Uninit(); }