新增回調
- 在使用過程中,輸出之后還需要手動拷貝到服務器上會麻煩,一旦未拷貝編輯器還會因為加載(同步加載)的問題卡死。所以可以到Unity的PacakgeCache中修改本地倉庫中的Addressable對應版本的包。找不到位置可以用everything搜索一下,一般都在C盤中
- 在AddressableAssetSettings 新增回調
public static Action<bool> OnBuildFinish;public static Action<bool> OnUpdateBuildFinish;
- 在AddressableAssetSettings.BuildPlayerContentImpl中將原有的輸出結果檢測邏輯替換為下面的邏輯
if (!string.IsNullOrEmpty(result.Error)){Debug.LogError(result.Error);Debug.LogError($"Addressable content build failure (duration : {TimeSpan.FromSeconds(result.Duration).ToString("g")})");OnBuildFinish?.invork(false);}else{Debug.Log($"Addressable content successfully built (duration : {TimeSpan.FromSeconds(result.Duration).ToString("g")})");OnBuildFinish?.invork(false);}
- 在ContentUpdateScript.BuildContentUpdate中將原有的輸出結果檢測邏輯替換為下面的邏輯
if (!string.IsNullOrEmpty(result.Error)){AddressableAssets.OnUpdateBuildFinish?.Invork(false);Debug.LogError(result.Error);}else{AddressableAssets.OnUpdateBuildFinish?.Invork(true);}