private void UpdateBytesAssetBundleCreateRequest() { if (m_BytesAssetBundleCreateRequest != null) { if (m_BytesAssetBundleCreateRequest.isDone) { AssetBundle assetBundle = m_BytesAssetBundleCreateRequest.assetBundle; if (assetBundle != null) { AssetBundleCreateRequest oldBytesAssetBundleCreateRequest = m_BytesAssetBundleCreateRequest; LoadResourceAgentHelperParseBytesCompleteEventArgs loadResourceAgentHelperParseBytesCompleteEventArgs = LoadResourceAgentHelperParseBytesCompleteEventArgs.Create(assetBundle); m_LoadResourceAgentHelperParseBytesCompleteEventHandler(this, loadResourceAgentHelperParseBytesCompleteEventArgs); ReferencePool.Release(loadResourceAgentHelperParseBytesCompleteEventArgs); if (m_BytesAssetBundleCreateRequest == oldBytesAssetBundleCreateRequest) { m_BytesAssetBundleCreateRequest = null; m_LastProgress = 0f; } } else { LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.NotExist, "Can not load asset bundle from memory which is not a valid asset bundle."); m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs); ReferencePool.Release(loadResourceAgentHelperErrorEventArgs); } } else if (m_BytesAssetBundleCreateRequest.progress != m_LastProgress) { m_LastProgress = m_BytesAssetBundleCreateRequest.progress; LoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = LoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadResource, m_BytesAssetBundleCreateRequest.progress); m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs); ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs); } } }
/// <summary> /// 创建加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件。 /// </summary> /// <param name="resource">资源对象。</param> /// <returns>创建的加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件。</returns> public static LoadResourceAgentHelperParseBytesCompleteEventArgs Create(object resource) { LoadResourceAgentHelperParseBytesCompleteEventArgs loadResourceAgentHelperParseBytesCompleteEventArgs = ReferencePool.Acquire <LoadResourceAgentHelperParseBytesCompleteEventArgs>(); loadResourceAgentHelperParseBytesCompleteEventArgs.Resource = resource; return(loadResourceAgentHelperParseBytesCompleteEventArgs); }