public void Dispose() { m_ResourceManager = null; m_DataProviderHelper = null; m_LoadAssetCallbacks = null; m_LoadBinaryCallbacks = null; }
/// <summary> /// 初始化数据提供者的新实例。 /// </summary> /// <param name="owner">数据提供者的持有者。</param> public DataProvider(T owner) { m_Owner = owner; m_LoadAssetCallbacks = new LoadAssetCallbacks(LoadAssetSuccessCallback, LoadAssetOrBinaryFailureCallback, LoadAssetUpdateCallback, LoadAssetDependencyAssetCallback); m_LoadBinaryCallbacks = new LoadBinaryCallbacks(LoadBinarySuccessCallback, LoadAssetOrBinaryFailureCallback); m_ResourceManager = null; m_DataProviderHelper = null; }
/// <summary> /// 异步加载二进制资源。 /// </summary> /// <param name="binaryAssetName">要加载二进制资源的名称。</param> /// <param name="loadBinaryCallbacks">加载二进制资源回调函数集。</param> /// <param name="userData">用户自定义数据。</param> public void LoadBinary(string binaryAssetName, LoadBinaryCallbacks loadBinaryCallbacks, object userData) { ResourceInfo resourceInfo = GetResourceInfo(binaryAssetName, AssetCategory.Binary); if (resourceInfo == null) { string errorMessage = Utility.Text.Format("Can not load binary '{0}' which is not exist.", binaryAssetName); if (loadBinaryCallbacks.LoadBinaryFailureCallback != null) { loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.NotExist, errorMessage, userData); return; } throw new Exception(errorMessage); } if (!resourceInfo.Ready) { string errorMessage = Utility.Text.Format("Can not load binary '{0}' which is not ready.", binaryAssetName); if (loadBinaryCallbacks.LoadBinaryFailureCallback != null) { loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.NotReady, errorMessage, userData); return; } throw new Exception(errorMessage); } if (!resourceInfo.IsLoadFromBinary) { string errorMessage = Utility.Text.Format("Can not load binary '{0}' which is not a binary asset.", binaryAssetName); if (loadBinaryCallbacks.LoadBinaryFailureCallback != null) { loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.TypeError, errorMessage, userData); return; } throw new Exception(errorMessage); } if (resourceInfo.UseFileSystem) { loadBinaryCallbacks.LoadBinarySuccessCallback(binaryAssetName, LoadBinaryFromFileSystem(binaryAssetName), 0f, userData); } else { string path = Utility.Path.GetRemotePath(Path.Combine(resourceInfo.StorageInReadOnly ? m_ResourceComponent.ReadOnlyPath : m_ResourceComponent.ReadWritePath, resourceInfo.ResourceName.FullName)); m_ResourceComponent.ResourceHelper.LoadBytes(path, m_LoadBytesCallbacks, LoadBinaryInfo.Create(binaryAssetName, resourceInfo, loadBinaryCallbacks, userData)); } }