diff --git a/Docs/AssetBundleBuilder.md b/Docs/AssetBundleBuilder.md index 309dc6c..4dbfbef 100644 --- a/Docs/AssetBundleBuilder.md +++ b/Docs/AssetBundleBuilder.md @@ -52,6 +52,20 @@ (4) BundleName_HashName_Extension:资源包名+哈希值+后缀名 + - **Copy Buildin File Option** + + 首包资源文件的拷贝方式 + + (1) None:不拷贝任何文件 + + (2) ClearAndCopyAll:先清空已有文件,然后拷贝所有文件 + + (3) ClearAndCopyByTags:先清空已有文件,然后按照资源标签拷贝文件 + + (4) OnlyCopyAll:不清空已有文件,直接拷贝所有文件 + + (5) OnlyCopyByTags:不清空已有文件,直接按照资源标签拷贝文件 + - **构建** 点击构建按钮会开始构建流程,构建流程分为多个节点顺序执行,如果某个节点发生错误,会导致构建失败。错误信息可以在控制台查看。 @@ -126,6 +140,7 @@ private static void BuildInternal(BuildTarget buildTarget) buildParameters.EncryptionServices = new GameEncryption(); buildParameters.CompressOption = ECompressOption.LZ4; buildParameters.OutputNameStyle = EOutputNameStyle.HashName_Extension; + buildParameters.CopyBuildinFileOption = ECopyBuildinFileOption.None; // 执行构建 AssetBundleBuilder builder = new AssetBundleBuilder(); diff --git a/Docs/AssetBundleCollector.md b/Docs/AssetBundleCollector.md index 0f99b94..ac9d48b 100644 --- a/Docs/AssetBundleCollector.md +++ b/Docs/AssetBundleCollector.md @@ -10,6 +10,10 @@ #### 公共设置 +- Show Packages + + 是否展示资源包列表视图。 + - Enable Addressable 启用可寻址资源定位系统。 diff --git a/Docs/CodeTutorial1.md b/Docs/CodeTutorial1.md index 2ad86b4..3e780a8 100644 --- a/Docs/CodeTutorial1.md +++ b/Docs/CodeTutorial1.md @@ -3,7 +3,14 @@ 初始化资源系统 ```c# +// 初始化资源系统 YooAssets.Initialize(); + +// 创建默认的资源包 +var defaultPackage = YooAssets.CreateAssetsPackage("DefaultPackage"); + +// 设置该资源包为默认的资源包,可以使用YooAssets相关加载接口加载该资源包内容。 +YooAssets.SetDefaultAssetsPackage(defaultPackage); ``` 资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。 @@ -17,10 +24,10 @@ YooAssets.Initialize(); ````c# private IEnumerator InitializeYooAsset() { - var initParameters = new YooAssets.EditorSimulateModeParameters(); + var initParameters = new EditorSimulateModeParameters(); initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes"); - initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage", false); - yield return YooAssets.InitializeAsync(initParameters); + initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage"); + yield return defaultPackage.InitializeAsync(initParameters); } ```` @@ -33,9 +40,9 @@ private IEnumerator InitializeYooAsset() ````c# private IEnumerator InitializeYooAsset() { - var initParameters = new YooAssets.OfflinePlayModeParameters(); + var initParameters = new OfflinePlayModeParameters(); initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes"); - yield return YooAssets.InitializeAsync(initParameters); + yield return defaultPackage.InitializeAsync(initParameters); } ```` @@ -55,22 +62,22 @@ private IEnumerator InitializeYooAsset() - DecryptionServices : 如果资源包在构建的时候有加密,需要提供实现IDecryptionServices接口的实例类。 +- QueryServices:内置资源查询服务接口。 + - DefaultHostServer : 默认的资源服务器IP地址。 - FallbackHostServer : 备用的资源服务器IP地址。 -- VerifyLevel : 下载文件校验等级 - ````c# private IEnumerator InitializeYooAsset() { - var initParameters = new YooAssets.HostPlayModeParameters(); + var initParameters = new HostPlayModeParameters(); initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes"); initParameters.DecryptionServices = new BundleDecryptionServices(); initParameters.QueryServices = new QueryStreamingAssetsServices(); initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android/v1.0"; initParameters.FallbackHostServer = "http://127.0.0.1/CDN2/Android/v1.0"; - yield return YooAssets.InitializeAsync(initParameters); + yield return defaultPackage.InitializeAsync(initParameters); } // 文件解密服务类 @@ -88,7 +95,8 @@ private class QueryStreamingAssetsServices : IQueryServices public bool QueryStreamingAssets(string fileName) { // 注意:使用了BetterStreamingAssets插件 - return BetterStreamingAssets.FileExists($"YooAssets/{fileName}"); + string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName(); + return BetterStreamingAssets.FileExists($"{buildinFolderName}/{fileName}"); } } ```` diff --git a/Docs/CodeTutorial2.md b/Docs/CodeTutorial2.md index 013a8af..d6f15f4 100644 --- a/Docs/CodeTutorial2.md +++ b/Docs/CodeTutorial2.md @@ -9,7 +9,8 @@ ````c# private IEnumerator UpdateStaticVersion() { - UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync(); + var package = YooAssets.GetAssetsPackage("DefaultPackage"); + UpdateStaticVersionOperation operation = package.UpdateStaticVersionAsync(); yield return operation; if (operation.Status == EOperationStatus.Succeed) @@ -33,7 +34,8 @@ private IEnumerator UpdateStaticVersion() ````c# private IEnumerator UpdatePatchManifest() { - UpdateManifestOperation operation = YooAssets.UpdateManifestAsync(packageCRC); + var package = YooAssets.GetAssetsPackage("DefaultPackage"); + UpdateManifestOperation operation = package.UpdateManifestAsync(packageCRC); yield return operation; if (operation.Status == EOperationStatus.Succeed) @@ -56,15 +58,15 @@ private IEnumerator UpdatePatchManifest() 补丁包下载接口: -- YooAssets.CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain) +- YooAssets.CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout) 用于下载更新当前资源版本所有的资源包文件。 -- YooAssets.CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain) +- YooAssets.CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) 用于下载更新资源标签指定的资源包文件。 -- YooAssets.CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain) +- YooAssets.CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout) 用于下载更新指定的资源列表依赖的资源包文件。 @@ -73,7 +75,8 @@ IEnumerator Download() { int downloadingMaxNum = 10; int failedTryAgain = 3; - DownloaderOperation downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain); + int timeout = 60; + var downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain, timeout); //没有需要下载的资源 if (downloader.TotalDownloadCount == 0) @@ -114,7 +117,8 @@ IEnumerator Download() ````c# private IEnumerator UpdateStaticVersion() { - UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync(10); + var package = YooAssets.GetAssetsPackage("DefaultPackage"); + UpdateStaticVersionOperation operation = package.UpdateStaticVersionAsync(10); yield return operation; if (operation.Status == EOperationStatus.Succeed) { @@ -135,7 +139,7 @@ private IEnumerator UpdateStaticVersion() } // 在弱联网情况下更新补丁清单 - UpdateManifestOperation operation2 = YooAssets.WeaklyUpdateManifestAsync(packageCRC); + UpdateManifestOperation operation2 = package.WeaklyUpdateManifestAsync(packageCRC); yield return operation2; if (operation2.Status == EOperationStatus.Succeed) { diff --git a/Docs/CodeTutorial3.md b/Docs/CodeTutorial3.md index 27b5274..5b6c25a 100644 --- a/Docs/CodeTutorial3.md +++ b/Docs/CodeTutorial3.md @@ -18,9 +18,9 @@ ```c# // 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3" // 设定资源路径的根目录为:"Assets/GameRes",后续加载的资源定位地址填写相对路径:"Audio/bgMusic" -var createParameters = new YooAssets.EditorSimulateModeParameters(); +var createParameters = new EditorSimulateModeParameters(); createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes"); -yield return YooAssets.InitializeAsync(createParameters); +yield return defaultPackage.InitializeAsync(createParameters); ...... YooAssets.LoadAssetAsync("Audio/bgMusic"); ``` @@ -31,9 +31,9 @@ YooAssets.LoadAssetAsync("Audio/bgMusic"); // 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3" // 需要在资源配置界面启用可寻址功能(Enable Addressable)。 // 配置界面的可寻址规则为AddressByFileName,那么资源定位地址填写文件名称:"bgMusic" -var createParameters = new YooAssets.EditorSimulateModeParameters(); +var createParameters = new EditorSimulateModeParameters(); createParameters.LocationServices = new AddressLocationServices(); -yield return YooAssets.InitializeAsync(createParameters); +yield return defaultPackage.InitializeAsync(createParameters); ...... YooAssets.LoadAssetAsync("bgMusic"); ```` @@ -104,7 +104,8 @@ IEnumerator Start() ````c# private void UnloadAssets() { - YooAssets.UnloadUnusedAssets(); + var package = YooAssets.GetAssetsPackage("DefaultPackage"); + package.UnloadUnusedAssets(); } ```` diff --git a/Docs/CodeTutorial4.md b/Docs/CodeTutorial4.md index 848ea54..b245431 100644 --- a/Docs/CodeTutorial4.md +++ b/Docs/CodeTutorial4.md @@ -65,7 +65,7 @@ go.transform.localScale = Vector3.one; 在运行游戏之前,请保证资源包可以构建成功! ```c# -public static YooAssetPackage AssetPackage; +public static AssetPackage DefaultPackage; IEnumerator Start() { @@ -73,24 +73,24 @@ IEnumerator Start() YooAssets.Initialize(); // 创建资源包实例 - AssetPackage = YooAssets.CreateAssetPackage("DefaultPackage"); + DefaultPackage = YooAssets.CreateAssetPackage("DefaultPackage"); // 初始化资源包 ...... - yield return AssetPackage.InitializeAsync(createParameters); + yield return DefaultPackage.InitializeAsync(createParameters); // 更新资源包版本 ...... - var operation = AssetPackage.UpdateManifestAsync(packageCRC); + var operation = DefaultPackage.UpdateManifestAsync(packageCRC); yield return operation; // 下载更新文件 - var downloader = AssetPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain); + var downloader = DefaultPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain); downloader.BeginDownload(); yield return downloader; // 加载资源对象 - var assetHandle = AssetPackage.LoadAssetAsync("Assets/GameRes/npc.prefab"); + var assetHandle = DefaultPackage.LoadAssetAsync("Assets/GameRes/npc.prefab"); yield return assetHandle; ...... } diff --git a/Docs/FAQ.md b/Docs/FAQ.md index f96c29e..ddab281 100644 --- a/Docs/FAQ.md +++ b/Docs/FAQ.md @@ -17,6 +17,10 @@ windows平台添加命令: **-force-gles** YooAsset依赖于ScriptBuildPipeline(SBP),在PackageManager里找到SBP插件安装就可以了。 +#### 问题:使用FileZilla等FTP上传工具后,文件下载总是验证失败 + +把传输类型修改为二进制就可以了。 + #### 问题:YooAsset支持Unity2018吗 YooAsset分俩部分,编辑器代码和运行时代码。因为工具界面是使用UIElements编写的,所以在Unity2019以前的版本是使用不了界面化工具。但是这并没有影响我们使用YooAsset,以下提供一种解决方案。 diff --git a/Docs/Image/AssetBuilder-img1.png b/Docs/Image/AssetBuilder-img1.png index 2500785..3ccc7e1 100644 Binary files a/Docs/Image/AssetBuilder-img1.png and b/Docs/Image/AssetBuilder-img1.png differ