在项目中使用Addressable打包时遇到一个问题,面对多个平台打包时,需要每次都Switch Platform一次,才可以打对应的包。比较繁琐,这边提供一个解决方案。
实现在 Unity 编辑器中选择要构建的 Addressable 资源的目标平台,然后根据选择的平台执行打包操作。具体代码如下:
using UnityEditor;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Settings;
using UnityEditor.AddressableAssets.Settings.GroupSchemas;
using UnityEngine;
namespace AddressableBundle
{
public class AddressablePlatformBuilder : EditorWindow
{
private BuildTargetGroup buildTargetGroup = BuildTargetGroup.Standalone;
private BuildTarget buildTarget = BuildTarget.StandaloneWindows;
[MenuItem("Tools/Addressable Platform Builder")]
public static void ShowWindow()
{
GetWindow<AddressablePlatformBuilder>("Addressable Pla