From 8b14189ab2084db3d103b9cbb5e878f56b1559ae Mon Sep 17 00:00:00 2001 From: Takumi Shimomura Date: Thu, 11 Sep 2025 18:56:36 +0900 Subject: [PATCH 1/4] =?UTF-8?q?AAS=E3=81=AEsortOrder=E3=82=92LayoutRuleEdi?= =?UTF-8?q?tor=E3=81=AB=E5=8F=8D=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LayoutRuleEditor/LayoutRuleEditorPresenter.cs | 12 +++++++++++- .../Editor/SmartAddresser.Editor.asmdef | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs index eab6c5d..cf73757 100644 --- a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs +++ b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs @@ -17,6 +17,7 @@ using UnityEditor; using UnityEditor.AddressableAssets; using UnityEditor.AddressableAssets.Settings; +using UnityEditor.AddressableAssets.Settings.GroupSchemas; using UnityEngine; namespace SmartAddresser.Editor.Core.Tools.Addresser.LayoutRuleEditor @@ -110,7 +111,16 @@ private void SetupActiveView(LayoutRuleData data) _editingData.Value = data; _assetSaveService.SetAsset(data); - if (data.LayoutRule.SyncAddressRulesWithAddressableAssetGroups(addressableAssetSettings.groups)) + var groups = addressableAssetSettings.groups; + +#if AAS_SORT_ORDER + var orderSettings = AddressableAssetGroupSortSettings.GetSettings(addressableAssetSettings); + groups = addressableAssetSettings.groups + .OrderBy(g => Array.IndexOf(orderSettings.sortOrder, g.Guid)) + .ToList(); +#endif + + if (data.LayoutRule.SyncAddressRulesWithAddressableAssetGroups(groups)) _assetSaveService.MarkAsDirty(); _addressRuleEditorPresenter.SetupView(data.LayoutRule.AddressRules); diff --git a/Assets/SmartAddresser/Editor/SmartAddresser.Editor.asmdef b/Assets/SmartAddresser/Editor/SmartAddresser.Editor.asmdef index 9d68cc3..8da1389 100644 --- a/Assets/SmartAddresser/Editor/SmartAddresser.Editor.asmdef +++ b/Assets/SmartAddresser/Editor/SmartAddresser.Editor.asmdef @@ -15,6 +15,17 @@ "precompiledReferences": [], "autoReferenced": true, "defineConstraints": [], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.unity.addressables", + "expression": "[1.23.1,2.0.0)", + "define": "AAS_SORT_ORDER" + }, + { + "name": "com.unity.addressables", + "expression": "2.3.7", + "define": "AAS_SORT_ORDER" + } + ], "noEngineReferences": false } \ No newline at end of file From 8d47fa84970c43a718e952857cb48cd82933b0f3 Mon Sep 17 00:00:00 2001 From: Takumi Shimomura Date: Fri, 19 Sep 2025 16:19:40 +0900 Subject: [PATCH 2/4] =?UTF-8?q?LayoutViewer=E3=81=AB=E3=82=82Group?= =?UTF-8?q?=E4=B8=A6=E3=81=B3=E9=A0=86=E3=82=92=E5=8F=8D=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LayoutRuleEditorPresenter.cs | 2 +- .../LayoutViewer/LayoutViewerPresenter.cs | 38 ++++++++++++------- .../LayoutViewer/LayoutViewerWindow.cs | 36 ++++++++++++++++++ 3 files changed, 61 insertions(+), 15 deletions(-) diff --git a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs index cf73757..169a3c8 100644 --- a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs +++ b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs @@ -112,7 +112,7 @@ private void SetupActiveView(LayoutRuleData data) _assetSaveService.SetAsset(data); var groups = addressableAssetSettings.groups; - + #if AAS_SORT_ORDER var orderSettings = AddressableAssetGroupSortSettings.GetSettings(addressableAssetSettings); groups = addressableAssetSettings.groups diff --git a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs index 214aa95..0078593 100644 --- a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs +++ b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs @@ -9,6 +9,8 @@ using SmartAddresser.Editor.Foundation.TinyRx; using SmartAddresser.Editor.Foundation.TinyRx.ObservableProperty; using UnityEditor; +using UnityEditor.AddressableAssets; +using UnityEditor.AddressableAssets.Settings.GroupSchemas; using UnityEngine; using UnityEngine.Assertions; @@ -47,13 +49,6 @@ public void Dispose() _editingData.Dispose(); } - private void AddGroupView(Group group, bool reload = true) - { - _view.TreeView.AddGroup(group); - if (reload) - _view.TreeView.Reload(); - } - public void SetupView(ILayoutRuleDataRepository dataRepository) { _setupViewDisposables.Clear(); @@ -84,9 +79,7 @@ private void SetupActiveView(LayoutRuleData data) layout.Validate(false, validationSettings.DuplicateAddresses, validationSettings.DuplicateAssetPaths, validationSettings.EntryHasMultipleVersions); _layout = layout; - foreach (var group in layout.Groups) - AddGroupView(group); - _view.TreeView.Reload(); + ApplyGroupsToTreeView(); _view.ActiveMode.Value = LayoutViewerView.Mode.Viewer; _view.ActiveAssetName.Value = data.name; @@ -185,15 +178,32 @@ void OnRefreshButtonClicked() validationSettings.EntryHasMultipleVersions); _layout = layout; - _view.TreeView.ClearItems(); - foreach (var group in layout.Groups) - AddGroupView(group); - _view.TreeView.Reload(); + ApplyGroupsToTreeView(); } #endregion } + public void ApplyGroupsToTreeView() + { + _view.TreeView.ClearItems(); + + if (_layout == null) + { + return; + } + + var addressableAssetSettings = AddressableAssetSettingsDefaultObject.Settings; + var orderSettings = AddressableAssetGroupSortSettings.GetSettings(addressableAssetSettings); + foreach (var group in _layout.Groups.OrderBy(g => + Array.IndexOf(orderSettings.sortOrder, g.AddressableGroup.Guid))) + { + _view.TreeView.AddGroup(group); + } + + _view.TreeView.Reload(); + } + private void CleanupViewEventHandlers() { _view.TreeView.OnSelectionChanged -= OnTreeViewSelectionChanged; diff --git a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs index cad426a..c55d06f 100644 --- a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs +++ b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs @@ -5,6 +5,8 @@ using SmartAddresser.Editor.Foundation.EditorSplitView; using SmartAddresser.Editor.Foundation.TinyRx; using UnityEditor; +using UnityEditor.AddressableAssets; +using UnityEditor.AddressableAssets.Settings; using UnityEngine; namespace SmartAddresser.Editor.Core.Tools.Addresser.LayoutViewer @@ -21,14 +23,28 @@ internal sealed class LayoutViewerWindow : EditorWindow private LayoutViewerPresenter _presenter; private LayoutViewerView _view; + private AddressableAssetSettings _addressableAssetSettings; + private void OnEnable() { minSize = new Vector2(600, 200); Setup(); + + _addressableAssetSettings = AddressableAssetSettingsDefaultObject.Settings; + if (_addressableAssetSettings) + { + _addressableAssetSettings.OnModification += OnAddressableAssetSettingsModified; + } } private void OnDisable() { + if (_addressableAssetSettings) + { + _addressableAssetSettings.OnModification -= OnAddressableAssetSettingsModified; + _addressableAssetSettings = null; + } + _presenter?.Dispose(); _view?.Dispose(); } @@ -66,5 +82,25 @@ public static void Open() { GetWindow(WindowName); } + + private void OnAddressableAssetSettingsModified( + AddressableAssetSettings settings, + AddressableAssetSettings.ModificationEvent e, + object obj) + { + // AssetGroupの並び順反映 + if (e == AddressableAssetSettings.ModificationEvent.GroupMoved) + { + _presenter.ApplyGroupsToTreeView(); + } + + // コールバックを末尾に登録しなおす + // AssetGroupの並び順はOnModificationコールバック内でシリアライズされるので、それより後に更新しないと反映できないため + if (_addressableAssetSettings) + { + _addressableAssetSettings.OnModification -= OnAddressableAssetSettingsModified; + _addressableAssetSettings.OnModification += OnAddressableAssetSettingsModified; + } + } } } From 653c332ff133084894a9ec94c248fcf97789056a Mon Sep 17 00:00:00 2001 From: Takumi Shimomura Date: Fri, 19 Sep 2025 17:02:04 +0900 Subject: [PATCH 3/4] =?UTF-8?q?GroupMoved=E3=82=A4=E3=83=99=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=AA=E3=82=89=E9=81=85=E5=BB=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LayoutRuleEditor/LayoutRuleEditorPresenter.cs | 3 ++- .../Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs | 10 +--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs index 169a3c8..bdd85ab 100644 --- a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs +++ b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutRuleEditor/LayoutRuleEditorPresenter.cs @@ -142,11 +142,12 @@ object obj ) { if (e == AddressableAssetSettings.ModificationEvent.GroupAdded - || e == AddressableAssetSettings.ModificationEvent.GroupMoved || e == AddressableAssetSettings.ModificationEvent.GroupRemoved || e == AddressableAssetSettings.ModificationEvent.GroupRenamed) // If the addressable asset group is changed, reload. SetupActiveView(_editingData.Value); + else if (e == AddressableAssetSettings.ModificationEvent.GroupMoved) + EditorApplication.delayCall += () => SetupActiveView(_editingData.Value); } public void CleanupView() diff --git a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs index c55d06f..2baf5e3 100644 --- a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs +++ b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerWindow.cs @@ -91,15 +91,7 @@ private void OnAddressableAssetSettingsModified( // AssetGroupの並び順反映 if (e == AddressableAssetSettings.ModificationEvent.GroupMoved) { - _presenter.ApplyGroupsToTreeView(); - } - - // コールバックを末尾に登録しなおす - // AssetGroupの並び順はOnModificationコールバック内でシリアライズされるので、それより後に更新しないと反映できないため - if (_addressableAssetSettings) - { - _addressableAssetSettings.OnModification -= OnAddressableAssetSettingsModified; - _addressableAssetSettings.OnModification += OnAddressableAssetSettingsModified; + EditorApplication.delayCall += () => _presenter.ApplyGroupsToTreeView(); } } } From 0505f0532300b78816530e8d79e9baa7cb446b29 Mon Sep 17 00:00:00 2001 From: Takumi Shimomura Date: Wed, 24 Sep 2025 17:11:17 +0900 Subject: [PATCH 4/4] =?UTF-8?q?ifdef=E6=BC=8F=E3=82=8C=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs index 0078593..93bb4c9 100644 --- a/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs +++ b/Assets/SmartAddresser/Editor/Core/Tools/Addresser/LayoutViewer/LayoutViewerPresenter.cs @@ -193,6 +193,7 @@ public void ApplyGroupsToTreeView() return; } +#if AAS_SORT_ORDER var addressableAssetSettings = AddressableAssetSettingsDefaultObject.Settings; var orderSettings = AddressableAssetGroupSortSettings.GetSettings(addressableAssetSettings); foreach (var group in _layout.Groups.OrderBy(g => @@ -200,6 +201,12 @@ public void ApplyGroupsToTreeView() { _view.TreeView.AddGroup(group); } +#else + foreach (var group in _layout.Groups) + { + _view.TreeView.AddGroup(group); + } +#endif _view.TreeView.Reload(); }