diff --git a/Assets/00.StaryEvoTools/Editor/Build/BuildApkWindow.cs b/Assets/00.StaryEvoTools/Editor/Build/BuildApkWindow.cs index 01f8c6e..8e42f7a 100644 --- a/Assets/00.StaryEvoTools/Editor/Build/BuildApkWindow.cs +++ b/Assets/00.StaryEvoTools/Editor/Build/BuildApkWindow.cs @@ -30,25 +30,104 @@ namespace Stary.Evo.Editor [Title("设备类型选择", titleAlignment: TitleAlignments.Centered)] [EnumToggleButtons, HideLabel] public DeviceType deviceType = DeviceType.Xreal; - [Title("包裹列表", titleAlignment: TitleAlignments.Centered)] - [LabelText("Domain子包")] - [ValueDropdown("GetAvailablePackageNames")] - [OnValueChanged("OnPackageNameChanged")] - public string selectedPackageName; + #region 包体列表 - [LabelText("自定义App名称")] - [Tooltip("空置时为默认名")] - public string productNameReplace; + [TitleGroup("Domain子包", alignment: TitleAlignments.Centered)] + [LabelText("选择包体")] + [HideIf(nameof(allowMutiSelection))] + [ValueDropdown(nameof(GetAvailablePackageNames))] + [OnValueChanged(nameof(OnPackageNameChanged))] + public string selectedPackageName; - [TitleGroup("打包配置", alignment: TitleAlignments.Centered)] [ToggleLeft] [LabelText("自动递增版本号")] + [TitleGroup("Domain子包")] + [LabelText("允许多选")] + public bool allowMutiSelection = false; + + [TitleGroup("Domain子包")] + [LabelText("选择包体")] + [ShowIf(nameof(allowMutiSelection))] + [ValueDropdown(nameof(GetAvailablePackageNames))] + public string[] selectionOfPackages; + + [TitleGroup("Domain子包")] + [LabelText("查看包体配置")] + [ShowIf(nameof(allowMutiSelection))] + [OnValueChanged(nameof(OnPackageSelectedOptionChanged))] + [ValueDropdown(nameof(selectionOfPackages))] + public string selectedOptionOfselectionOfPackages; + + [BoxGroup("Domain子包/包体配置")] + [InlineProperty, HideLabel] + [ShowIf(nameof(selectedPackageInfo))] + public PackageConfigInfo selectedPackageInfo; + + /// + /// 获取可用的包裹名称列表 + /// + /// 包裹名称列表 + private List GetAvailablePackageNames() + { + UpdateAvailablePackages(); + return CreatAssetWindow.GetCreatDomainAllName().ToList(); + } + + /// + /// 更新可用包裹列表 + /// + private void UpdateAvailablePackages() + { + var availablePackages = CreatAssetWindow.GetCreatDomainAllName().ToList(); + if (availablePackages.Any() && string.IsNullOrEmpty(selectedPackageName)) + { + selectedPackageName = availablePackages.First(); + } + } + + /// + /// 当包裹名称改变时的回调 + /// + private void OnPackageNameChanged(string packageID) + { + buildStatus = "就绪"; + + selectedPackageInfo = HotfixMainResDomain.Get.buildConfig.Get(packageID).info; + } + + /// + /// 当可选包体中选择的包体改变时的回调 + /// + /// + private void OnPackageSelectedOptionChanged(string packageID) + { + selectedPackageInfo = HotfixMainResDomain.Get.buildConfig.Get(packageID).info; + } + + #endregion + + #region 打包配置 + + [TitleGroup("打包配置", alignment: TitleAlignments.Centered)] + [ToggleLeft] + [LabelText("自动递增版本号")] public bool autoIncrementVersion = true; - [TitleGroup("打包配置", alignment: TitleAlignments.Centered)] [ToggleLeft] [LabelText("是否添加水印")] + [TitleGroup("打包配置")] + [ToggleLeft] + [LabelText("是否添加水印")] public bool isWatermark = false; - [TitleGroup("打包配置", alignment: TitleAlignments.Centered)] [ToggleLeft] [LabelText("是否服务器热更包")] + + [TitleGroup("打包配置")] + [ToggleLeft] + [LabelText("是否服务器热更包")] [OnValueChanged("OnServerChangedTag")] public bool isServer = false; - [ToggleLeft] [LabelText("构建完成后打开文件夹")] public bool openFolderOnComplete = true; + + [TitleGroup("打包配置")] + [ToggleLeft] + [LabelText("构建完成后打开文件夹")] + public bool openFolderOnComplete = true; + + #endregion [BoxGroup("缓存管理", centerLabel: true)] [Button("清空打包缓存", ButtonSizes.Large)] @@ -230,7 +309,7 @@ namespace Stary.Evo.Editor packageName = selectedPackageName; } - PlayerSettings.productName = productNameReplace.IsNullOrEmpty() ? productName : productNameReplace; + PlayerSettings.productName = string.IsNullOrEmpty(selectedPackageInfo?.appName) ? productName : selectedPackageInfo.appName; PlayerSettings.applicationIdentifier = packageName; // 自动递增版本号 @@ -243,8 +322,6 @@ namespace Stary.Evo.Editor /// /// 配置场景列表 /// - /// 是否为水印包 - /// 资源配置 /// 场景路径数组 private string[] ConfigureScenes() { @@ -297,7 +374,7 @@ namespace Stary.Evo.Editor /// private void ConfigureWatermark() { - if (productNameReplace.IsNullOrEmpty()) + if (string.IsNullOrEmpty(selectedPackageInfo?.appName)) { PlayerSettings.productName += "_watermark"; } @@ -497,36 +574,6 @@ namespace Stary.Evo.Editor } } - /// - /// 获取可用的包裹名称列表 - /// - /// 包裹名称列表 - private List GetAvailablePackageNames() - { - UpdateAvailablePackages(); - return CreatAssetWindow.GetCreatDomainAllName().ToList(); - } - - /// - /// 更新可用包裹列表 - /// - private void UpdateAvailablePackages() - { - var availablePackages = CreatAssetWindow.GetCreatDomainAllName().ToList(); - if (availablePackages.Any() && string.IsNullOrEmpty(selectedPackageName)) - { - selectedPackageName = availablePackages.First(); - } - } - - /// - /// 当包裹名称改变时的回调 - /// - private void OnPackageNameChanged() - { - buildStatus = "就绪"; - } - /// /// 自动递增版本号 /// diff --git a/Assets/00.StaryEvoTools/Editor/HotfixMainResDomainEditor.cs b/Assets/00.StaryEvoTools/Editor/HotfixMainResDomainEditor.cs index fee5917..d6be188 100644 --- a/Assets/00.StaryEvoTools/Editor/HotfixMainResDomainEditor.cs +++ b/Assets/00.StaryEvoTools/Editor/HotfixMainResDomainEditor.cs @@ -1,37 +1,15 @@ -using System.Collections; -using System.Collections.Generic; +using Sirenix.OdinInspector.Editor; using Stary.Evo; -using Stary.Evo.Editor; using UnityEditor; -using UnityEngine; [CustomEditor(typeof(HotfixMainResDomain))] -public class HotfixMainResDomainEditor : UnityEditor.Editor +public class HotfixMainResDomainEditor : OdinEditor { - /// - /// 序列化属性,在OnEnable中获取 - /// - [HideInInspector] - private SerializedProperty projectInfo; - - private void OnEnable() - { - projectInfo = serializedObject.FindProperty("projectInfo"); - - } - public override void OnInspectorGUI() { base.OnInspectorGUI(); - HotfixMainResDomain hotfixMainResDomain = (HotfixMainResDomain)target; - hotfixMainResDomain.projectInfo.projectPackageName = $"com.xosmo.{hotfixMainResDomain.projectInfo.projectCode}"; - - if (hotfixMainResDomain.projectInfo.loadingScene == null) - { - Debug.LogError("HotfixMainResDomain 资源中loadingScene索引不存在,请检查!"); - return; - } - // 获取loadingScene的Assets相对路径 - hotfixMainResDomain.projectInfo.loadingScenePath = AssetDatabase.GetAssetPath(hotfixMainResDomain.projectInfo.loadingScene); + + var config = (HotfixMainResDomain)target; + config.projectInfo.projectPackageName = $"com.xosmo.{config.projectInfo.projectCode}"; } } \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/package.json b/Assets/00.StaryEvoTools/package.json index 8d4c62b..aeaf629 100644 --- a/Assets/00.StaryEvoTools/package.json +++ b/Assets/00.StaryEvoTools/package.json @@ -1,6 +1,6 @@ { "name": "com.staryevo.tools", - "version": "1.3.30", + "version": "1.3.31", "displayName": "00.StaryEvo.Tools", "description": "This is an Framework package(后台服务器版本,端口9527)", "unity": "2021.3",