/// <summary> /// Load an asset via its location. The asset will actually be loaded via the AssetDatabase API. /// </summary> /// <typeparam name="TObject"></typeparam> /// <param name="location"></param> /// <returns></returns> public IAsyncOperation <TObject> LoadAssetAsync <TObject>(IResourceLocation location) where TObject : class { if (location == null) { throw new ArgumentException("IResourceLocation location cannot be null."); } if (m_BundleLoadOperation == null) { return(new CompletedOperation <TObject>().Start(location, location, default(TObject), new ResourceManagerException("LoadAssetAsync called on unloaded bundle " + m_Name))); } if (!m_BundleLoadOperation.IsDone) { return(new CompletedOperation <TObject>().Start(location, location, default(TObject), new ResourceManagerException("LoadAssetAsync called on loading bundle " + m_Name))); } VirtualAssetBundleEntry assetInfo; if (!m_AssetMap.TryGetValue(location.InternalId, out assetInfo)) { return(new CompletedOperation <TObject>().Start(location, location, default(TObject), new ResourceManagerException(string.Format("Unable to load asset {0} from simulated bundle {1}.", location.InternalId, Name)))); } LoadAssetOp <TObject> op = new LoadAssetOp <TObject>(location, assetInfo); m_AssetLoadOperations.Add(op); return(op); }
/// <summary> /// Load an asset via its location. The asset will actually be loaded via the AssetDatabase API. /// </summary> /// <typeparam name="TObject"></typeparam> /// <param name="location"></param> /// <returns></returns> internal VBAsyncOperation <object> LoadAssetAsync(ProvideHandle provideHandle, IResourceLocation location) { if (location == null) { throw new ArgumentException("IResourceLocation location cannot be null."); } if (m_BundleLoadOperation == null) { return(new VBAsyncOperation <object>().StartCompleted(location, location, null, new ResourceManagerException("LoadAssetAsync called on unloaded bundle " + m_Name))); } if (!m_BundleLoadOperation.IsDone) { return(new VBAsyncOperation <object>().StartCompleted(location, location, null, new ResourceManagerException("LoadAssetAsync called on loading bundle " + m_Name))); } VirtualAssetBundleEntry assetInfo; //this needs to use the non translated internal id since that was how the table was built. if (!m_AssetMap.TryGetValue(location.InternalId, out assetInfo)) { return(new VBAsyncOperation <object>().StartCompleted(location, location, null, new ResourceManagerException(string.Format("Unable to load asset {0} from simulated bundle {1}.", location.InternalId, Name)))); } var op = new LoadAssetOp(location, assetInfo, provideHandle); m_AssetLoadOperations.Add(op); return(op); }
/// <summary> /// Load an asset via its location. The asset will actually be loaded via the AssetDatabase API. /// </summary> /// <typeparam name="TObject"></typeparam> /// <param name="location"></param> /// <returns></returns> internal VBAsyncOperation <object> LoadAssetAsync(Type type, IResourceLocation location) { if (location == null) { throw new ArgumentException("IResourceLocation location cannot be null."); } if (m_BundleLoadOperation == null) { return(new VBAsyncOperation <object>().StartCompleted(location, location, null, new ResourceManagerException("LoadAssetAsync called on unloaded bundle " + m_Name))); } if (!m_BundleLoadOperation.IsDone) { return(new VBAsyncOperation <object>().StartCompleted(location, location, null, new ResourceManagerException("LoadAssetAsync called on loading bundle " + m_Name))); } VirtualAssetBundleEntry assetInfo; if (!m_AssetMap.TryGetValue(location.InternalId, out assetInfo)) { return(new VBAsyncOperation <object>().StartCompleted(location, location, null, new ResourceManagerException(string.Format("Unable to load asset {0} from simulated bundle {1}.", location.InternalId, Name)))); } var op = new LoadAssetOp <object>(location, assetInfo); m_AssetLoadOperations.Add(op); return(op); }