Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -132,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらも
#if AAS_SORT_ORDER
が必要そうでしょうか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

失礼しました!#ifを追加して、sortOrderのないバージョンでエラーにならないことを再確認しました
こちらでマージしますね

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}
Expand Down Expand Up @@ -66,5 +82,17 @@ public static void Open()
{
GetWindow<LayoutViewerWindow>(WindowName);
}

private void OnAddressableAssetSettingsModified(
AddressableAssetSettings settings,
AddressableAssetSettings.ModificationEvent e,
object obj)
{
// AssetGroupの並び順反映
if (e == AddressableAssetSettings.ModificationEvent.GroupMoved)
{
EditorApplication.delayCall += () => _presenter.ApplyGroupsToTreeView();
}
}
}
}
13 changes: 12 additions & 1 deletion Assets/SmartAddresser/Editor/SmartAddresser.Editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -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
}