private void CollectOperation(T key, AddressableUtils.AsyncOperationHandleDisposable <V> operation) { if (_collectedOperations.ContainsKey(key)) { _collectedOperations[key].Add(operation); } else { _collectedOperations.Add(key, new List <AddressableUtils.AsyncOperationHandleDisposable <V> >()); _collectedOperations[key].Add(operation); } }
public IEnumerator LoadPrefab(T key, Action <V> onComplete) { if (_prefabCache.ContainsKey(key)) { yield break; } AddressableUtils.AsyncOperationHandleDisposable <V> operation = _addressableService.LoadAsync <V>(_prefabPathDictionary[key]); yield return(operation.WaitDone()); if (!_prefabCache.ContainsKey(key)) { _prefabCache.Add(key, operation.Result); } onComplete.Invoke(operation.Result); CollectOperation(key, operation); }
public async Task <V> LoadPrefab(T key) { if (_prefabCache.ContainsKey(key)) { return(null); } AddressableUtils.AsyncOperationHandleDisposable <V> operation = _addressableService.LoadAsync <V>(_prefabPathDictionary[key]); await operation.Task; if (!_prefabCache.ContainsKey(key)) { _prefabCache.Add(key, operation.Result); } CollectOperation(key, operation); return(operation.Result); }