void StartSingleLineLoad() { if (_prefabLoadList.Count <= 0) { return; } if (_state == ResourceLoadStateType.Loading) { return; } var res = _prefabLoadList[0]; PrefabRequest prefabReq = null; var prefabName = res.PrefabName; var callBack = res.CallBack; _prefabLoadList.Remove(res); if (HasPrefabRequest(prefabName, out prefabReq)) { _state = ResourceLoadStateType.Loading; prefabReq.Load(callBack); } else { Debug.LogWarning("Couldn't find prefabRequest " + prefabName); } }
public bool HasPrefabRequest(string prefabName, out PrefabRequest prefabRequest) { if (_prefabRequestDict.TryGetValue(prefabName, out prefabRequest)) { return(true); } return(false); }
public PrefabRequest Acquire(PrefabContentKey contentKey, Action <GameObject, PrefabRequest> callback = null) { PrefabRequest prefabRequest = new PrefabRequest { IsComplete = false, ContentKey = contentKey }; CoroutineRunner.Start(gameObjectContentCache.Acquire(contentKey, delegate(GameObject x) { onPrefabLoaded(x, prefabRequest, callback); }), this, "Loading Prefab Asset"); return(prefabRequest); }
void LoadAssetBundleConfig() { _prefabRequestDict.Clear(); var txt = LoadConfigFile(ASSETBUNDLE_CONFIG); JsonData jsonData = JsonMapper.ToObject(txt); if (jsonData["Prefabs"].IsArray) { for (int i = 0; i < jsonData["Prefabs"].Count; i++) { var jsonObj = jsonData["Prefabs"][i]; var req = new PrefabRequest(); req.Init(jsonObj["PrefabName"].ToString(), jsonObj["PrefabPath"].ToString(), jsonObj["ResourcePath"].ToString(), _isAssetBundle); _prefabRequestDict.Add(jsonObj["PrefabName"].ToString(), req); } } }
private void onPrefabLoaded(GameObject prefab, PrefabRequest request, Action <GameObject, PrefabRequest> callback) { request.Prefab = prefab; request.IsComplete = true; callback?.Invoke(prefab, request); }