示例#1
0
 /// <summary>
 /// 资源更新器轮询
 /// </summary>
 /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位</param>
 /// <param name="realElapseSeconds">真实流逝时间,以秒为单位</param>
 public void OnUpdate(float deltaTime, float unscaledDeltaTime)
 {
     if (m_UpdateAllowed)
     {
         if (m_UpdateWaitingInfo.Count > 0)
         {
             if (GameEntry.Download.FreeAgentCount > 0)
             {
                 UpdateInfo updateInfo = m_UpdateWaitingInfo[0];
                 m_UpdateWaitingInfo.RemoveAt(0);
                 GameEntry.Download.AddDownload(updateInfo.ResourcePath, PathUtil.GetRemotePath(m_ResourceManager.UpdatePrefixUri, PathUtil.GetResourceNameWithCrc32AndSuffix(updateInfo.ResourceName, updateInfo.HashCode)), updateInfo);
                 m_UpdatingCount++;
             }
         }
         else if (m_UpdatingCount <= 0)
         {
             m_UpdateAllowed = false;
             PathUtil.RemoveEmptyDirectory(m_ResourceManager.ReadWritePath);
             if (ResourceUpdateAllComplete != null)
             {
                 ResourceUpdateAllComplete(UpdateFailureCount <= 0);
             }
         }
     }
 }
示例#2
0
        /// <summary>
        /// 初始化资源
        /// </summary>
        public void InitResources()
        {
            if (GameEntry.Resource.ResourceHelper == null)
            {
                throw new Exception("Resource helper is invalid.");
            }

            GameEntry.Resource.ResourceHelper.LoadBytes(PathUtil.GetRemotePath(GameEntry.Resource.ReadOnlyPath, PathUtil.GetResourceNameWithSuffix(VersionListFileName)), ParsePackageList);
        }
示例#3
0
        /// <summary>
        /// 预加载Shader
        /// </summary>
        /// <param name="preLoadShaderCallBack">预加载shader回调函数集</param>
        public void PreLoadShader(PreLoadShaderCallBack preLoadShaderCallBack)
        {
            if (m_ResourceHelper == null)
            {
                throw new Exception("Please set resourceHelper first!");
            }

            m_PreLoadShaderCallBack = preLoadShaderCallBack;
            ResourceInfo resourceInfo = GameEntry.Resource.GetResourceInfo("shader");

            m_ResourceHelper.LoadBytes(PathUtil.GetRemotePath(resourceInfo.StorageInReadOnly ? GameEntry.Resource.ReadOnlyPath : GameEntry.Resource.ReadWritePath, PathUtil.GetResourceNameWithSuffix(resourceInfo.ResourceName)), OnLoadShdaerBytesComplete);
        }
示例#4
0
        /// <summary>
        /// 读取2进制流
        /// </summary>
        /// <param name="fullPath"></param>
        private void ReadBytes(string fullPath)
        {
#if UNITY_5_4_OR_NEWER
            m_UnityWebRequest = UnityWebRequest.Get(PathUtil.GetRemotePath(fullPath));
#if UNITY_2017_2_OR_NEWER
            m_UnityWebRequest.SendWebRequest();
#else
            m_UnityWebRequest.Send();
#endif
#else
            m_WWW = new WWW(PathUtil.GetRemotePath(fullPath));
#endif
        }
示例#5
0
        /// <summary>
        /// 异步加载主依赖项
        /// </summary>
        internal void LoadManifestAsync(LoadManifestCompleteCallBack loadManifestCompleteCallBack)
        {
            LoadManifestCompleteCallBack = loadManifestCompleteCallBack;
            string assetName = string.Empty;

#if UNITY_STANDALONE_WIN
            assetName = "windows";
#elif UNITY_ANDROID
            assetName = "android";
#elif UNITY_IPHONE
            assetName = "ios";
#endif
            ResourceInfo resourceInfo = GetResourceInfo(assetName);
            m_ResourceHelper.LoadBytes(PathUtil.GetRemotePath(resourceInfo.StorageInReadOnly ? GameEntry.Resource.ReadOnlyPath : GameEntry.Resource.ReadWritePath, PathUtil.GetResourceNameWithSuffix(assetName)), OnLoadManifestCallBack);
        }
示例#6
0
        /// <summary>
        /// 只读目录读文件
        /// </summary>
        /// <param name="assetName">资源名称</param>
        private void ReadOnlyByte(string assetName)
        {
            m_FilePath = PathUtil.GetRemotePath(GameEntry.Resource.ReadOnlyPath, PathUtil.GetResourceNameWithSuffix(assetName));

#if UNITY_5_4_OR_NEWER
            m_UnityWebRequest = UnityWebRequest.Get(m_FilePath);
#if UNITY_2017_2_OR_NEWER
            m_UnityWebRequest.SendWebRequest();
#else
            m_UnityWebRequest.Send();
#endif
#else
            m_WWW = new WWW(m_FilePath);
#endif
        }
示例#7
0
        /// <summary>
        /// 更新版本资源列表
        /// </summary>
        /// <param name="versionListLength">版本资源列表大小</param>
        /// <param name="versionListHashCode">版本资源列表哈希值</param>
        /// <param name="versionListZipLength">版本资源列表压缩后大小</param>
        /// <param name="versionListZipHashCode">版本资源列表压缩后哈希值</param>
        public void UpdateVersionList(int versionListLength, int versionListHashCode, int versionListZipLength, int versionListZipHashCode)
        {
            if (GameEntry.Download == null)
            {
                throw new Exception("You must set download manager first.");
            }

            m_VersionListLength      = versionListLength;
            m_VersionListHashCode    = versionListHashCode;
            m_VersionListZipLength   = versionListZipLength;
            m_VersionListZipHashCode = versionListZipHashCode;
            string versionListFileName       = PathUtil.GetResourceNameWithSuffix(VersionListFileName);
            string latestVersionListFileName = PathUtil.GetResourceNameWithCrc32AndSuffix(VersionListFileName, m_VersionListHashCode);
            string localVersionListFilePath  = PathUtil.GetCombinePath(m_ResourceManager.ReadWritePath, versionListFileName);
            string latestVersionListFileUri  = PathUtil.GetRemotePath(m_ResourceManager.UpdatePrefixUri, latestVersionListFileName);

            GameEntry.Download.AddDownload(localVersionListFilePath, latestVersionListFileUri, this);
        }
示例#8
0
        public void CheckResources()
        {
            TryRecoverReadWriteList();

            if (GameEntry.Resource.ResourceHelper == null)
            {
                throw new Exception("Resource helper is invalid.");
            }

            if (string.IsNullOrEmpty(m_ResourceManager.ReadOnlyPath))
            {
                throw new Exception("Readonly path is invalid.");
            }

            if (string.IsNullOrEmpty(m_ResourceManager.ReadWritePath))
            {
                throw new Exception("Read-write path is invalid.");
            }

            GameEntry.Resource.ResourceHelper.LoadBytes(PathUtil.GetRemotePath(GameEntry.Resource.ReadWritePath, PathUtil.GetResourceNameWithSuffix(VersionListFileName)), ParseVersionList);
            GameEntry.Resource.ResourceHelper.LoadBytes(PathUtil.GetRemotePath(GameEntry.Resource.ReadOnlyPath, PathUtil.GetResourceNameWithSuffix(ResourceListFileName)), ParseReadOnlyList);
            GameEntry.Resource.ResourceHelper.LoadBytes(PathUtil.GetRemotePath(GameEntry.Resource.ReadWritePath, PathUtil.GetResourceNameWithSuffix(ResourceListFileName)), ParseReadWriteList);
        }