Exemple #1
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);
        }
Exemple #2
0
 public AssetLoader(int id)
 {
     status         = eLoadStatus.idle;
     resID          = ResID.New(id);
     resourceModule = Mango.GetModule <ResourceModule>();
 }