示例#1
0
        public static ResID New(int id)
        {
            ResID resID;

            if (!cacheIDs.TryGetValue(id, out resID))
            {
                resID = new ResID(id);
            }
            return(resID);
        }
示例#2
0
        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);
        }
示例#3
0
        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));
            }
        }
示例#4
0
 public AssetLoader(int id)
 {
     status         = eLoadStatus.idle;
     resID          = ResID.New(id);
     resourceModule = Mango.GetModule <ResourceModule>();
 }
示例#5
0
 public static string GetBundleName(ResID resID)
 {
     return(null);
 }