Scene: Added "Include Build Scenes", when sorting scenes into sub-menu

This commit is contained in:
Anders Ejlersen 2025-03-31 19:04:13 +02:00
parent 29ab1a90a0
commit 8b927d1997
5 changed files with 70 additions and 6 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@ -51,8 +52,10 @@ namespace Module.NavigationTool.Editor.Toolbar
}
else if (group.behaviourType == ESceneGroupBehaviourType.SortInSubmenuAsGroup)
{
var rectOptional = new Rect(rect.x, rectType.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight);
var rectIncludeBuildScenes = new Rect(rect.x, rectType.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight);
var rectOptional = new Rect(rect.x, rectIncludeBuildScenes.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight);
rectLabels = new Rect(rect.x, rectOptional.yMax + 2f, rect.width, rect.height - (rectName.y - rectOptional.yMax) - 4f);
group.includeBuildScenes = EditorGUI.Toggle(rectIncludeBuildScenes, "Include Build Scenes", group.includeBuildScenes);
group.subMenuPath = EditorGUI.TextField(rectOptional, "Sub-menu Path", group.subMenuPath);
}
@ -85,10 +88,26 @@ namespace Module.NavigationTool.Editor.Toolbar
protected override float OnElementHeight(int index)
{
int labelCount = list[index].filters.Count;
float extra;
switch (list[index].behaviourType)
{
case ESceneGroupBehaviourType.LoadAsGroup:
extra = 98f;
break;
case ESceneGroupBehaviourType.SortAsGroup:
extra = 80f;
break;
case ESceneGroupBehaviourType.SortInSubmenuAsGroup:
extra = 120f;
break;
default:
throw new ArgumentOutOfRangeException();
}
return base.OnElementHeight(index) * 3f
+ Mathf.Max(0, labelCount - 1) * (EditorGUIUtility.singleLineHeight + 2f)
+ 104f;
+ extra;
}
}
}