示例#1
0
 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);
     }
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }