public virtual IPromise <T> Load() { if (loadPromise != null) { return(loadPromise); } loadPromise = Promise <T> .Create(); if (HasValue == false) { loadPromise.Reject(new EntryPointNotFoundException("Link doesn't have any value")); return(loadPromise); } #if USE_ADDRESSABLES if (loaded || AssetCache.Loaded(Path)) { loadPromise.Resolve(Value); return(loadPromise); } if (IsGenerated()) { cachedAsset = App.Core.Storage.Load <T>(this); Initialize(cachedAsset); loaded = cachedAsset != null; loadPromise.Resolve(cachedAsset); return(loadPromise); } loadHandle = Addressables.LoadAssetAsync <T>(Path); loadHandle.Value.Completed += a => { if (Loaded == false) { if (a.Status == AsyncOperationStatus.Succeeded) { cachedAsset = a.Result; Initialize(cachedAsset); loaded = cachedAsset != null; loadPromise.Resolve(a.Result); } else { var e = new EntryPointNotFoundException($"Cannot load value from link: {Path}"); UnityEngine.Debug.LogException(e); loadPromise.Reject(e); } } }; #else if (loaded) { loadPromise.Resolve(Value); return(loadPromise); } if (IsGenerated()) { cachedAsset = App.Core.Storage.Load <T>(this); Initialize(cachedAsset); loaded = cachedAsset != null; loadPromise.Resolve(cachedAsset); return(loadPromise); } loadHandle = Resources.LoadAsync <T>(Path); loadHandle.completed += r => { if (Loaded == false && loadHandle.isDone && loadHandle.asset) { cachedAsset = loadHandle.asset as T; Initialize(cachedAsset); loaded = cachedAsset != null; loadPromise.Resolve(cachedAsset); } else { loadPromise.Reject(new EntryPointNotFoundException($"Cannot load resource of type {typeof(T)} at path {Path}")); } }; #endif return(loadPromise); }