Exemplo n.º 1
0
 private void UpdateWWW()
 {
     if (m_WWWLoader != null)
     {
         if (m_WWWLoader.IsCompleted)
         {
             if (string.IsNullOrEmpty(m_WWWLoader.Www.error))
             {
                 m_LoadResourceAgentHelperReadBytesCompleteEventHandler(this, new LoadResourceAgentHelperReadBytesCompleteEventArgs(m_WWWLoader.Www.bytes, m_LoadType));
                 m_WWWLoader.Release(true);
                 m_WWWLoader     = null;
                 m_BytesFullPath = null;
                 m_LoadType      = 0;
             }
             else
             {
                 m_LoadResourceAgentHelperErrorEventHandler(this, new LoadResourceAgentHelperErrorEventArgs(LoadResourceStatus.NotExist, string.Format("Can not load asset bundle '{0}' with error message '{1}'.", m_BytesFullPath, m_WWWLoader.Www.error)));
             }
         }
         else
         {
             m_LoadResourceAgentHelperUpdateEventHandler(this, new LoadResourceAgentHelperUpdateEventArgs(LoadResourceProgress.ReadBundle, m_WWWLoader.Progress));
         }
     }
 }
Exemplo n.º 2
0
        private IEnumerator CoLoad(string url)
        {
            if (_loaderMode == LoaderMode.Sync)
            {
                if (Application.isEditor) // Editor mode : 读取Product配置目录
                {
                    Bytes = KResourceLoader.ReadAllBytes(url);
                }
                else
                {
                    Bytes = KResourceLoader.LoadSyncByPlatform(url);
                }
            }
            else
            {
                _wwwLoader = KWWWLoader.Load(url);
                while (!_wwwLoader.IsCompleted)
                {
                    Progress = _wwwLoader.Progress;
                    yield return(null);
                }

                if (!_wwwLoader.IsSuccess)
                {
                    Log.Error("[HotBytesLoader]Error Load WWW: {0}", url);
                    OnFinish(null);
                    yield break;
                }

                Bytes = _wwwLoader.Www.bytes;
            }

            OnFinish(Bytes);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 通过加载资源代理辅助器开始异步读取资源二进制流。
        /// </summary>
        /// <param name="fullPath">要加载资源的完整路径名。</param>
        /// <param name="loadType">资源加载方式。</param>
        public override void ReadBytes(string fullPath, int loadType)
        {
            if (m_LoadResourceAgentHelperReadBytesCompleteEventHandler == null || m_LoadResourceAgentHelperUpdateEventHandler == null || m_LoadResourceAgentHelperErrorEventHandler == null)
            {
                Log.Fatal("Load resource agent helper handler is invalid.");
                return;
            }

            m_BytesFullPath = fullPath;
            m_LoadType      = loadType;

            m_WWWLoader = KWWWLoader.Load(Utility.Path.GetRemotePath(fullPath));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 释放资源。
        /// </summary>
        /// <param name="disposing">释放资源标记。</param>
        private void Dispose(bool disposing)
        {
            if (m_Disposed)
            {
                return;
            }

            if (disposing)
            {
                if (m_WWWLoader != null)
                {
                    m_WWWLoader.ForceDispose();
                    m_WWWLoader = null;
                }
            }

            m_Disposed = true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 重置加载资源代理辅助器。
        /// </summary>
        public override void Reset()
        {
            m_FileFullPath      = null;
            m_BytesFullPath     = null;
            m_LoadType          = 0;
            m_ResourceChildName = null;

            if (m_WWWLoader != null)
            {
                m_WWWLoader.Release(true);
                m_WWWLoader = null;
            }

            m_FileAssetBundleCreateRequest  = null;
            m_BytesAssetBundleCreateRequest = null;
            m_AssetBundleRequest            = null;
            m_AsyncOperation = null;
        }