//public void recyclePoolData(string url,GameObject gameobject, BumResourcePoolType resourcePoolType) //{ // Dictionary<string, List<GameObject>> tempDci; // List<GameObject> tempList; // bool checkDic = resourcePoolDic.TryGetValue(resourcePoolType,out tempDci); // if (checkDic == false) return; // bool checkKey = tempDci.TryGetValue(url, out tempList); // resourcePoolDic[resourcePoolType][url].Add(Rest(gameobject, resourcePoolType)); //} //private GameObject getPoolObject(string url, BumResourcePoolType resourcePoolType) //{ // Dictionary<string, List<GameObject>> tempDci; // List<GameObject> tempList; // GameObject GO = null; // bool checkDic = resourcePoolDic.TryGetValue(resourcePoolType, out tempDci); // if (checkDic == false) return null; // bool checkKey = tempDci.TryGetValue(url, out tempList); // if (tempList.Count>0) // { // GO = tempList[0]; // tempList.Remove(GO); // } // return GO; //} private GameObject Rest(GameObject go, BumResourcePoolType resourcePoolType) { switch (resourcePoolType) { case BumResourcePoolType.FactoryObject: go.transform.SetParent(factoryObject); break; case BumResourcePoolType.ZoneObject: go.transform.SetParent(zoneObject); break; case BumResourcePoolType.ProductObject: go.transform.SetParent(productObject); break; default: break; } go.transform.position = Vector3.zero; go.transform.rotation = Quaternion.identity; go.transform.localScale = Vector3.one; go.SetActive(false); return(go); }
//unity封装www加载resources public void loadFromWWW(string url, Action <object> onloaded, Action <object> progressEvent, BumResourceType resType = BumResourceType.eBumResourceType_assetBundle, BumResourcePoolType resourceTyep = BumResourcePoolType.ProductObject, object param = null, Action <GameObject, object> beforeClone = null) { //if (checkPoolData( url, onloaded, null, resType, resourceTyep, param, beforeClone)) return; bool existAssetCache = checkCache(url, resType); switch (resType) { case BumResourceType.eBumResourceType_assetBundle: BumApp.Instance.StartCoroutine(loadAssetBundleFormWWW(url, onloaded, progressEvent, existAssetCache, param, beforeClone)); break; case BumResourceType.eBumResourceType_texture2D: BumApp.Instance.StartCoroutine(loadTexture2DFromWWW(url, onloaded, progressEvent, existAssetCache)); break; case BumResourceType.eBumResourceType_json: BumApp.Instance.StartCoroutine(loadJsonFromWWW(url, onloaded, progressEvent, false)); break; case BumResourceType.eBumResourceType_userInfo: BumApp.Instance.StartCoroutine(loadUserInfoJsonFromWWW(url, onloaded, progressEvent, existAssetCache)); break; default: break; } }
//private void recyclePoolData(string url,GameObject gameobject, BumResourcePoolType resourcePoolType) //{ // pool.recyclePoolData(url,gameobject,resourcePoolType); //} public void auto(string url, Action <object> onloaded, Action <object> progressEvent, BumResourceType resType = BumResourceType.eBumResourceType_assetBundle, BumResourcePoolType resourceType = BumResourcePoolType.ProductObject, object param = null, Action <GameObject, object> beforeClone = null) { if (checkLocal(url)) { loadFromLocal(url, onloaded); } loadFromWWW(url, onloaded, progressEvent, resType, resourceType, param, beforeClone); }
private bool checkPoolData(string url, Action <object> onloaded, Action <object> progressEvent, BumResourceType resType = BumResourceType.eBumResourceType_assetBundle, BumResourcePoolType resourcePoolType = BumResourcePoolType.ProductObject, object param = null, Action <GameObject, object> beforeClone = null) { return(pool.TryGet(url, onloaded, progressEvent, resType, resourcePoolType, param, beforeClone)); }
public static void loadResource(string url, Action <object> onloaded, Action <object> progressEvent = null, BumResourceType resType = BumResourceType.eBumResourceType_assetBundle, BumLoadingType loadingType = BumLoadingType.eBumLoadingType_www, BumResourcePoolType resourceType = BumResourcePoolType.ProductObject, object param = null, Action <GameObject, object> beforeClone = null) { switch (loadingType) { case BumLoadingType.eBumLoadingType_auto: loader.auto(url, onloaded, progressEvent, resType, resourceType, param, beforeClone); break; case BumLoadingType.eBumLoadingType_local: loader.loadFromLocal(url, onloaded); break; case BumLoadingType.eBumLoadingType_www: loader.loadFromWWW(url, onloaded, progressEvent, resType, resourceType, param, beforeClone); break; default: break; } }
public bool TryGet(string url, Action <object> onloaded, Action <object> progressEvent = null, BumResourceType resType = BumResourceType.eBumResourceType_assetBundle, BumResourcePoolType resourcePoolType = BumResourcePoolType.ProductObject, object param = null, Action <GameObject, object> beforeClone = null) { LoadPoolData loopdata = null; bool hasPool = poolDic.TryGetValue(url, out loopdata); if (hasPool) { if (onloaded != null) { onloaded(loopdata.resouce); } if (progressEvent != null) { progressEvent(1.0f); } if (beforeClone != null) { beforeClone(loopdata.resouce as GameObject, param); } } return(hasPool); //GameObject resource = getPoolObject(url, resourcePoolType); //if (resource == null) //{ // resource = (GameObject)GameObject.Instantiate<GameObject>(loopdata.resouce as GameObject); // Rest(resource, resourcePoolType); //} }