Scene Picker: Modified scene groups to contain LoadAsGroup, SortAsGroup and SortInSubmenuAsGroup

### Changed
-  Scene groups to contain three different types of behaviours for grouping:
   - Load As Group: Groups all scenes into a single entry
   - Sort As Group: Sorts all scenes into entries close to each other in the dropdown
   - Sort In Submenu As Group: Sorts all scenes into entries in a submenu

### Removed
- Removed "Scene sorting by Asset label" groups
This commit is contained in:
Anders Ejlersen 2025-03-29 11:12:03 +01:00
parent a7cb8e885b
commit dd80d46ebb
11 changed files with 128 additions and 71 deletions

View file

@ -24,26 +24,39 @@ namespace Module.NavigationTool.Editor.Toolbar
SceneGroup group = list[index];
var rectName = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
var rectType = new Rect(rect.x, rectName.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight);
var rectOptional = new Rect(rect.x, rectType.yMax + 2f, rect.width - 80f, EditorGUIUtility.singleLineHeight);
var rectOptionalBtn = new Rect(rectOptional.xMax, rectType.yMax + 2f, 80f, EditorGUIUtility.singleLineHeight);
var rectLabels = new Rect(rect.x, rectOptional.yMax + 2f, rect.width, rect.height - (rectName.y - rectOptional.yMax) - 4f);
var rectBehaviourType = new Rect(rect.x, rectName.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight);
var rectType = new Rect(rect.x, rectBehaviourType.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight);
var rectLabels = new Rect(rect.x, rectType.yMax + 2f, rect.width, rect.height - (rectName.y - rectType.yMax) - 4f);
EditorGUI.BeginChangeCheck();
group.name = EditorGUI.TextField(rectName, "Name", group.name);
group.optionalMainScenePath = EditorGUI.TextField(rectOptional, "Optional Main Scene Path", group.optionalMainScenePath);
if (GUI.Button(rectOptionalBtn, "Find"))
if (group.behaviourType == ESceneGroupBehaviourType.LoadAsGroup)
{
string mainScenePath = EditorUtility.OpenFilePanel("Scene", "Assets", "unity");
var rectOptional = new Rect(rect.x, rectType.yMax + 2f, rect.width - 80f, EditorGUIUtility.singleLineHeight);
var rectOptionalBtn = new Rect(rectOptional.xMax, rectType.yMax + 2f, 80f, EditorGUIUtility.singleLineHeight);
rectLabels = new Rect(rect.x, rectOptional.yMax + 2f, rect.width, rect.height - (rectName.y - rectOptional.yMax) - 4f);
group.optionalMainScenePath = EditorGUI.TextField(rectOptional, "Optional Main Scene Path", group.optionalMainScenePath);
if (!string.IsNullOrEmpty(mainScenePath))
if (GUI.Button(rectOptionalBtn, "Find"))
{
mainScenePath = mainScenePath.Substring(Application.dataPath.Length - 6);
group.optionalMainScenePath = mainScenePath;
string mainScenePath = EditorUtility.OpenFilePanel("Scene", "Assets", "unity");
if (!string.IsNullOrEmpty(mainScenePath))
{
mainScenePath = mainScenePath.Substring(Application.dataPath.Length - 6);
group.optionalMainScenePath = mainScenePath;
}
}
}
else if (group.behaviourType == ESceneGroupBehaviourType.SortInSubmenuAsGroup)
{
var rectOptional = new Rect(rect.x, rectType.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight);
rectLabels = new Rect(rect.x, rectOptional.yMax + 2f, rect.width, rect.height - (rectName.y - rectOptional.yMax) - 4f);
group.subMenuPath = EditorGUI.TextField(rectOptional, "Sub-menu Path", group.subMenuPath);
}
group.behaviourType = (ESceneGroupBehaviourType)EditorGUI.EnumPopup(rectBehaviourType, "Behaviour Type", group.behaviourType);
group.filterType = (ESceneGroupFilterType)EditorGUI.EnumPopup(rectType, "Filter Type", group.filterType);
elements[index].DoList(rectLabels);
@ -75,7 +88,7 @@ namespace Module.NavigationTool.Editor.Toolbar
return base.OnElementHeight(index) * 3f
+ Mathf.Max(0, labelCount - 1) * (EditorGUIUtility.singleLineHeight + 2f)
+ 78f;
+ 104f;
}
}
}