public void Load() { if (string.IsNullOrEmpty(url)) { Debug.LogError("NeedLoadstring.IsNullOrEmpty(url) == true"); return; } //Debug.LogWarning("NeedLoad"+url); state = SimpleLoadedState.Loading; ResourcesPool.LoadPoolData data; if (resourcePool.TryGet(keyUrl, out data)) { data.newUseTime = Time.realtimeSinceStartup; //Debug.LogError("LoadInPool + keyUrl = " + keyUrl); MyCallLater.Add(LoadInPool, 0, data); return; } bool add = resourcePool.addLoading(this); if (add) { if (loaders.Count < LoaderCount) { loaders.Add(this); StartLoad(); } else { loaderStack.Push(this); } } }
private void LoadInPool(object data) { //Debug.LogWarning("LoadInPool:"+uri); ResourcesPool.LoadPoolData poolData = data as ResourcesPool.LoadPoolData; if (poolData is ResourcesPool.ErrorData) { ResourcesPool.ErrorData errorData = poolData as ResourcesPool.ErrorData; errorData.errorCount++; //if (errorData.errorCount > errorData.MaxErrorCount) //{ progress = 1; this.state = SimpleLoadedState.Failed; this.dispatchEvent(new LoadEvent(LoadEvent.Complete, this)); return; //} } switch (poolData.type) { case ResourcesPool.PoolDataType.Json: loadedData = poolData.resouce; break; case ResourcesPool.PoolDataType.texture2D: loadedData = poolData.resouce; break; case ResourcesPool.PoolDataType.Prefab: ResourcesPool.PrefabData prefabData = poolData as ResourcesPool.PrefabData; if (canceled == false) { if (juseEndReturn == false) { loadedData = prefabData.GetNew(); } } break; case ResourcesPool.PoolDataType.Byte: default: loadedData = null; Debug.LogWarning("没有此类型的池!"); break; } EndOnly(); }