private void OnLoadBinaryFailure(string fileUri, string errorMessage, object userData)
        {
            LoadBinaryInfo loadBinaryInfo = (LoadBinaryInfo)userData;

            if (loadBinaryInfo == null)
            {
                throw new Exception("Load binary info is invalid.");
            }

            if (loadBinaryInfo.LoadBinaryCallbacks.LoadBinaryFailureCallback != null)
            {
                loadBinaryInfo.LoadBinaryCallbacks.LoadBinaryFailureCallback(loadBinaryInfo.BinaryAssetName, LoadResourceStatus.AssetError, errorMessage, loadBinaryInfo.UserData);
            }

            ReferencePool.Release(loadBinaryInfo);
        }
        private void OnLoadBinarySuccess(string fileUri, byte[] bytes, float duration, object userData)
        {
            LoadBinaryInfo loadBinaryInfo = (LoadBinaryInfo)userData;

            if (loadBinaryInfo == null)
            {
                throw new Exception("Load binary info is invalid.");
            }

            ResourceInfo resourceInfo = loadBinaryInfo.ResourceInfo;

            if (resourceInfo.LoadType == LoadType.LoadFromBinaryAndQuickDecrypt || resourceInfo.LoadType == LoadType.LoadFromBinaryAndDecrypt)
            {
                DecryptResourceCallback decryptResourceCallback = m_ResourceComponent.DecryptResourceCallback ?? DefaultDecryptResourceCallback;
                decryptResourceCallback(bytes, 0, bytes.Length, resourceInfo.ResourceName.Name, resourceInfo.ResourceName.Variant, resourceInfo.ResourceName.Extension, resourceInfo.StorageInReadOnly, resourceInfo.FileSystemName, (byte)resourceInfo.LoadType, resourceInfo.Length, resourceInfo.HashCode);
            }

            loadBinaryInfo.LoadBinaryCallbacks.LoadBinarySuccessCallback(loadBinaryInfo.BinaryAssetName, bytes, duration, loadBinaryInfo.UserData);
            ReferencePool.Release(loadBinaryInfo);
        }
        /// <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));
            }
        }