示例#1
0
 private void UpdateAsyncOperation()
 {
     if (m_AsyncOperation != null)
     {
         if (m_AsyncOperation.isDone)
         {
             if (m_AsyncOperation.allowSceneActivation)
             {
                 InnerLoadResourceAgentHelperLoadCompleteEventArgs loadResourceAgentHelperLoadCompleteEventArgs = InnerLoadResourceAgentHelperLoadCompleteEventArgs.Create(new SceneAsset());
                 m_LoadResourceAgentHelperLoadCompleteEventHandler(this, loadResourceAgentHelperLoadCompleteEventArgs);
                 ReferencePool.Release(loadResourceAgentHelperLoadCompleteEventArgs);
                 m_AssetName      = null;
                 m_LastProgress   = 0f;
                 m_AsyncOperation = null;
             }
             else
             {
                 InnerLoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = InnerLoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.AssetError, DBD.Utility.Text.Format("Can not load scene asset '{0}' from asset bundle.", m_AssetName));
                 m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
                 ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
             }
         }
         else if (m_AsyncOperation.progress != m_LastProgress)
         {
             m_LastProgress = m_AsyncOperation.progress;
             InnerLoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = InnerLoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadScene, m_AsyncOperation.progress);
             m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
             ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
         }
     }
 }
示例#2
0
 private void UpdateAssetBundleRequest()
 {
     if (m_AssetBundleRequest != null)
     {
         if (m_AssetBundleRequest.isDone)
         {
             if (m_AssetBundleRequest.asset != null)
             {
                 InnerLoadResourceAgentHelperLoadCompleteEventArgs loadResourceAgentHelperLoadCompleteEventArgs = InnerLoadResourceAgentHelperLoadCompleteEventArgs.Create(m_AssetBundleRequest.asset);
                 m_LoadResourceAgentHelperLoadCompleteEventHandler(this, loadResourceAgentHelperLoadCompleteEventArgs);
                 ReferencePool.Release(loadResourceAgentHelperLoadCompleteEventArgs);
                 m_AssetName          = null;
                 m_LastProgress       = 0f;
                 m_AssetBundleRequest = null;
             }
             else
             {
                 InnerLoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = InnerLoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.AssetError, DBD.Utility.Text.Format("Can not load asset '{0}' from asset bundle which is not exist.", m_AssetName));
                 m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
                 ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
             }
         }
         else if (m_AssetBundleRequest.progress != m_LastProgress)
         {
             m_LastProgress = m_AssetBundleRequest.progress;
             InnerLoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = InnerLoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadAsset, m_AssetBundleRequest.progress);
             m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
             ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
         }
     }
 }
示例#3
0
 private void UpdateFileAssetBundleCreateRequest()
 {
     if (m_FileAssetBundleCreateRequest != null)
     {
         if (m_FileAssetBundleCreateRequest.isDone)
         {
             AssetBundle assetBundle = m_FileAssetBundleCreateRequest.assetBundle;
             if (assetBundle != null)
             {
                 AssetBundleCreateRequest oldFileAssetBundleCreateRequest = m_FileAssetBundleCreateRequest;
                 InnerLoadResourceAgentHelperReadFileCompleteEventArgs loadResourceAgentHelperReadFileCompleteEventArgs = InnerLoadResourceAgentHelperReadFileCompleteEventArgs.Create(assetBundle);
                 m_LoadResourceAgentHelperReadFileCompleteEventHandler(this, loadResourceAgentHelperReadFileCompleteEventArgs);
                 ReferencePool.Release(loadResourceAgentHelperReadFileCompleteEventArgs);
                 if (m_FileAssetBundleCreateRequest == oldFileAssetBundleCreateRequest)
                 {
                     m_FileAssetBundleCreateRequest = null;
                     m_LastProgress = 0f;
                 }
             }
             else
             {
                 InnerLoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = InnerLoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.NotExist, Utility.Text.Format("Can not load asset bundle from file '{0}' which is not a valid asset bundle.", m_FileName == null ? m_FileFullPath : Utility.Text.Format("{0} | {1}", m_FileFullPath, m_FileName)));
                 m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
                 ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
             }
         }
         else if (m_FileAssetBundleCreateRequest.progress != m_LastProgress)
         {
             m_LastProgress = m_FileAssetBundleCreateRequest.progress;
             InnerLoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = InnerLoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadResource, m_FileAssetBundleCreateRequest.progress);
             m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
             ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
         }
     }
 }
示例#4
0
 private void UpdateBytesAssetBundleCreateRequest()
 {
     if (m_BytesAssetBundleCreateRequest != null)
     {
         if (m_BytesAssetBundleCreateRequest.isDone)
         {
             AssetBundle assetBundle = m_BytesAssetBundleCreateRequest.assetBundle;
             if (assetBundle != null)
             {
                 AssetBundleCreateRequest oldBytesAssetBundleCreateRequest = m_BytesAssetBundleCreateRequest;
                 InnerLoadResourceAgentHelperParseBytesCompleteEventArgs loadResourceAgentHelperParseBytesCompleteEventArgs = InnerLoadResourceAgentHelperParseBytesCompleteEventArgs.Create(assetBundle);
                 m_LoadResourceAgentHelperParseBytesCompleteEventHandler(this, loadResourceAgentHelperParseBytesCompleteEventArgs);
                 ReferencePool.Release(loadResourceAgentHelperParseBytesCompleteEventArgs);
                 if (m_BytesAssetBundleCreateRequest == oldBytesAssetBundleCreateRequest)
                 {
                     m_BytesAssetBundleCreateRequest = null;
                     m_LastProgress = 0f;
                 }
             }
             else
             {
                 InnerLoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = InnerLoadResourceAgentHelperErrorEventArgs.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;
             InnerLoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = InnerLoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadResource, m_BytesAssetBundleCreateRequest.progress);
             m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
             ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
         }
     }
 }
示例#5
0
        private void UpdateUnityWebRequest()
        {
            if (m_UnityWebRequest != null)
            {
                if (m_UnityWebRequest.isDone)
                {
                    if (string.IsNullOrEmpty(m_UnityWebRequest.error))
                    {
                        InnerLoadResourceAgentHelperReadBytesCompleteEventArgs loadResourceAgentHelperReadBytesCompleteEventArgs = InnerLoadResourceAgentHelperReadBytesCompleteEventArgs.Create(m_UnityWebRequest.downloadHandler.data);
                        m_LoadResourceAgentHelperReadBytesCompleteEventHandler(this, loadResourceAgentHelperReadBytesCompleteEventArgs);
                        ReferencePool.Release(loadResourceAgentHelperReadBytesCompleteEventArgs);
                        m_UnityWebRequest.Dispose();
                        m_UnityWebRequest = null;
                        m_BytesFullPath   = null;
                        m_LastProgress    = 0f;
                    }
                    else
                    {
                        bool isError = false;

                        isError = m_UnityWebRequest.isNetworkError || m_UnityWebRequest.isHttpError;

                        InnerLoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = InnerLoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.NotExist, DBD.Utility.Text.Format("Can not load asset bundle '{0}' with error message '{1}'.", m_BytesFullPath, isError ? m_UnityWebRequest.error : null));
                        m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
                        ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
                    }
                }
                else if (m_UnityWebRequest.downloadProgress != m_LastProgress)
                {
                    m_LastProgress = m_UnityWebRequest.downloadProgress;
                    InnerLoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = InnerLoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.ReadResource, m_UnityWebRequest.downloadProgress);
                    m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
                    ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
                }
            }
        }