using cfg; using SimpleJSON; using UnityEditor.AddressableAssets; using UnityEditor; using UnityEngine; using UnityEditor.AddressableAssets.Settings; using System.Linq; using System.IO; using addressables.helper; public class AddressableLabelHelper { const string tbmapdownloadresPath = "../cfgData/tbmapdownloadres.json"; [MenuItem("Window/Asset Management/Helper/Sync Groups", true)] static bool ValidateSyncGroups() => File.Exists(tbmapdownloadresPath) || AddressableHelper.IsSettingExists(); [MenuItem("Window/Asset Management/Helper/Sync Groups &#F")] public static void SyncGroups() { AddressableHelper.SyncGroups(); var jsonData = new TbMapDownloadRes(JSON.Parse(File.ReadAllText(tbmapdownloadresPath))); AddressableAssetSettings addrSettings = AddressableAssetSettingsDefaultObject.Settings; AddressableAssetGroup fishGroup = addrSettings.FindGroup("FishDownload"); AddressableAssetGroup fishFPGroup = addrSettings.FindGroup("FishFP"); AddressableAssetGroup EnvMapDownload = addrSettings.FindGroup("EnvMapDownload"); foreach (var groupDefine in jsonData.DataList) { Debug.Log($"[AddressableHelper] set label {groupDefine.Label}"); AddressableAssetGroup group = addrSettings.FindGroup(groupDefine.FishingResPack); if (null != group) { group.entries.ToList().ForEach(x => x.SetLabel(groupDefine.Label, true, true)); EditorUtility.SetDirty(group); //EditorUtility.SetDirty(group); //AssetDatabase.SaveAssets(); } if (fishGroup != null) { fishGroup.entries.Where(x => groupDefine.FishRes.Contains(x.address)).ToList().ForEach(x => x.SetLabel(groupDefine.Label, true, true)); EditorUtility.SetDirty(fishGroup); } if (fishFPGroup != null) { fishFPGroup.entries.Where(x => groupDefine.FishRes.Contains(x.address)).ToList().ForEach(x => x.SetLabel(groupDefine.Label, true, true)); EditorUtility.SetDirty(fishFPGroup); } if (EnvMapDownload != null) { EnvMapDownload.entries.Where(x => groupDefine.FishRes.Contains(x.address)).ToList().ForEach(x => x.SetLabel(groupDefine.Label, true, true)); EditorUtility.SetDirty(EnvMapDownload); } } EditorUtility.SetDirty(addrSettings); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }