public static ResID New(int id) { ResID resID; if (!cacheIDs.TryGetValue(id, out resID)) { resID = new ResID(id); } return(resID); }
public GameObject CreateGO(int id, Transform parent, bool active) { ResID resID = ResID.New(id); string assetName = resID.assetName; if (pool.ContainsKey(assetName)) { List <GameObject> goes = pool[assetName]; if (goes != null && goes.Count > 0) { GameObject go = goes[0]; go.transform.SetParent(parent); go.SetActive(active); goes.Remove(go); if (goes == null || goes.Count == 0) { pool.Remove(assetName); } return(go); } } List <string> groups; if (assetsMap.TryGetValue(resID, out groups)) { if (groups.Count > 0) { string groupName = groups[0]; if (groupMap.ContainsKey(groupName)) { List <IAssetLoader> loaders = groupMap[groupName]; if (loaders.Count > 0) { IAssetLoader loader = groupMap[groupName].Find(a => a.ResID.Equals(groupName)); GameObject prefab = loader.Load <GameObject>(); GameObject go = GameObject.Instantiate(prefab); go.transform.SetParent(parent); go.SetActive(active); return(go); } } } } return(null); }
private IEnumerator DoPreloadAsset(string groupName, List <IAssetLoader> loaders, Action onFinished, int index) { IAssetLoader loader = loaders[index]; IAssetAsynRequest request = loader.LoadAsyn(); yield return(request); index++; if (index >= loaders.Count) { groupMap.Add(groupName, loaders); for (int i = 0; i < loaders.Count; i++) { ResID resID = loaders[i].ResID; if (assetsMap.ContainsKey(resID)) { assetsMap[resID].Add(groupName); } else { assetsMap.Add(resID, new List <string> { groupName }); } } loading = false; if (onFinished != null) { onFinished(); } } else { StartCoroutine(DoPreloadAsset(groupName, loaders, onFinished, index)); } }
public AssetLoader(int id) { status = eLoadStatus.idle; resID = ResID.New(id); resourceModule = Mango.GetModule <ResourceModule>(); }
public static string GetBundleName(ResID resID) { return(null); }