团结引擎+Addressable+Instant Game打包抖音小游戏

团结引擎+Addressable+Instant Game打包抖音小游戏
们主要讲加入AddressableInstant Game之后的问题点。1、Instant Game打包Copy对应的CDN地址请注意这个CDN地址是绑定UOS官方后台的CDN地址需要在后台开启。2、在Profile配置如下首包资源只能选择Package目前首包选择CDN打包会有一个文件路径找不到而被中断。首包前缀可不填但一般还是填一下和Instant Game中的CDN地址一致。这是从build里走打包。另外还可以从TT的SDK工具上走打包流程点图上的ByteGame-TT SDK Tools-Build Tool先点构建WebGL再点转换WebGL包。但是我从这里走经常出现打包报错。所以建议使用上面的Build Setting里的Build。3、https://dummy.dummy.dummy/问题的处理这个问题是由于adressable的地址没有被instant game自动接管导致的可能抖音没有进行特殊处理在微信SDK和最新版的京东SDK里就不会有这个问题。在Unity里创建一个.cs文件SkipUnityLogo.cs不需要挂在任意脚本上只要放在工程的Assets目录下原理是用CDN地址来替换dummy的占位符。如果你能很好去调整addressable的地址也就不用管这个问题最简单的方式是adressable都改为默认地址这里用CDN的全地址来替换。如果出现了地址中资源404的情况是因为CDN那边没有上传或者没有做版本管控这个在替换地址中去掉release_by_badge/latest这一段即能解决但我们不要这么做按正常方式走接下来会说这个。#if !UNITY_EDITOR using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Scripting; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.ResourceLocations; /** * 跳过unity-logo */ [Preserve] public class SkipUnityLogo { [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)] private static void BeforeSplashScreen() { #if UNITY_WEBGL Application.focusChanged Application_focusChanged; #else System.Threading.Tasks.Task.Run(AsyncSkip); #endif } [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] private static void FixDouYinAddressablePath() { Debug.Log(启动dummy替换0); #if UNITY_WEBGL Debug.Log(启动dummy替换1); Addressables.InternalIdTransformFunc location { string internalId location.InternalId; // 核心强制把 dummy 域名删掉 if (internalId.StartsWith(https://dummy.dummy.dummy/)) { internalId internalId.Replace(https://dummy.dummy.dummy/, https://a.unity.cn/client_api/v1/buckets/xxxxxxxxxxxxxxxxxxxxxxxx/release_by_badge/latest/content/); } Debug.Log(启动dummy替换2); // 修复重复路径问题 StreamingAssets/StreamingAssets if (internalId.Contains(StreamingAssets/StreamingAssets)) { internalId internalId.Replace(StreamingAssets/StreamingAssets/, StreamingAssets/); } return internalId; }; Debug.Log(启动dummy替换3); #endif } #if UNITY_WEBGL private static void Application_focusChanged(bool obj) { Application.focusChanged - Application_focusChanged; SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate); } #else private static void AsyncSkip() { SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate); } #endif } #endif4、在UOS的存储桶的页面下载CLI工具windows版本。下载之后使用命令行打开第1步在cmd里输入根据你的路径去修改cd /d C:\Users\admin\Downloads\uas_win_V1.0.9 uas.exe第2步输入自己替换xxxx的ID分别为uos的appid和app secretuos后台直接复制全命令即可uas auth login --uos_app_id xxxxxxxxxx --uos_app_service_secret xxxxxxxxxxxx之前是uos_app_secret 但后面接的参数是uos_app_service_secret的官方把字段做了一次修正第3步输入xxxxx为你存储桶的ID也是CDN地址中v1/buckets/后面的一段respath为你build结束后的webgl的目录C:\MyGame\ByteGameOutput\webgluas entries sync --bucket xxxxxxxxxxxxx respath例uas entries sync --bucket xxxxxxxxxxxxx C:\MyGame\ByteGameOutput\webgl重点关注后面的路径当中不可以有空格否则CLI的上传可能会有问题。这样会上传你当前的build里的资源但是没有做版本管理。第4步增加版本管理xxxxx为你存储桶的ID也是CDN地址中v1/buckets/后面的一段uas releases create --bucket xxxxxxxxxxxxxx --notes LastestUpload这4步上传完成后就等于资源全部上传完了。