Scene: Added "Include Build Scenes", when sorting scenes into sub-menu
This commit is contained in:
parent
29ab1a90a0
commit
8b927d1997
|
|
@ -2,6 +2,12 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
|
||||
|
||||
## [1.11.2] - 2024-11-26
|
||||
|
||||
### Added
|
||||
- Added "Include Build Scenes", when sorting scenes into sub-menu
|
||||
|
||||
|
||||
## [1.11.1] - 2024-11-25
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
public string name;
|
||||
public ESceneGroupFilterType filterType;
|
||||
public ESceneGroupBehaviourType behaviourType;
|
||||
public bool includeBuildScenes;
|
||||
public string optionalMainScenePath;
|
||||
public string subMenuPath = "Submenu";
|
||||
public List<string> filters = new();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
{
|
||||
name = asset.name,
|
||||
shortname = asset.shortname,
|
||||
paths = { asset.path }
|
||||
paths = { asset.path },
|
||||
inBuildSettings = true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -120,6 +121,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
continue;
|
||||
|
||||
filteredScenes = FilterToUniques(filteredScenes);
|
||||
|
||||
if (sceneGroup.includeBuildScenes)
|
||||
filteredScenes = FilterAllExceptWithBuildScenes(filteredScenes, scenes);
|
||||
else
|
||||
filteredScenes = FilterAllExcept(filteredScenes, scenes);
|
||||
|
||||
if (filteredScenes.Count != 0)
|
||||
|
|
@ -195,6 +200,38 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
return filtered;
|
||||
}
|
||||
|
||||
private static List<WorkingSetScene> FilterAllExceptWithBuildScenes(List<WorkingSetScene> list, List<SceneElement> except, bool includeGroups = false)
|
||||
{
|
||||
var filtered = new List<WorkingSetScene>(list.Count);
|
||||
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
var contains = false;
|
||||
|
||||
for (var j = except.Count - 1; j >= 0; j--)
|
||||
{
|
||||
if (except[j].isGroup && !includeGroups)
|
||||
continue;
|
||||
if (!except[j].paths.Contains(list[i].path))
|
||||
continue;
|
||||
|
||||
if (except[j].inBuildSettings)
|
||||
{
|
||||
except.RemoveAt(j);
|
||||
break;
|
||||
}
|
||||
|
||||
contains = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!contains)
|
||||
filtered.Add(list[i]);
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
private void FetchAllLabels()
|
||||
{
|
||||
labels = new GUIContent[scenes.Count];
|
||||
|
|
@ -395,6 +432,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
public string shortname;
|
||||
public bool includeAsSelectable = true;
|
||||
public bool isGroup;
|
||||
public bool inBuildSettings;
|
||||
public readonly List<string> paths = new List<string>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.module.navigationtool",
|
||||
"version": "1.11.1",
|
||||
"version": "1.11.2",
|
||||
"displayName": "Module.NavigationTool",
|
||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||
"unity": "2019.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue