Compare commits

...

10 commits

Author SHA1 Message Date
Anders Ejlersen 708b99f763 Fixed issue, where changing DPI scaling on monitor would detach visual elements from toolbar and not reattach/rebuild 2025-09-21 14:26:04 +02:00
Anders Ejlersen a9576ce008 Added missing meta files 2025-06-18 18:04:14 +02:00
Anders Ejlersen 8572a31421 Upload files to "/" 2025-06-07 20:53:17 +00:00
Anders Ejlersen 733a7de800 Changed type lookup to use TypeCache, instead of iterating through all assemblies 2025-05-11 15:02:40 +02:00
Anders Ejlersen 8b927d1997 Scene: Added "Include Build Scenes", when sorting scenes into sub-menu 2025-03-31 19:04:13 +02:00
Anders Ejlersen 29ab1a90a0 Time scale: Added context menu to time scale, so it is possible to reset slider to 1.0 2025-03-29 17:19:16 +01:00
Anders Ejlersen dd80d46ebb 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
2025-03-29 11:12:03 +01:00
Anders Ejlersen a7cb8e885b 1.10.2: Fixed issue, where scene picker would not prompt about unsaved scene changes 2025-02-10 17:54:52 +01:00
Anders Ejlersen 6f657c4a71 1.10.1: Fixed issue, where scene picker settings wouldn't save, if removing a group element 2024-11-25 22:10:25 +01:00
Anders Ejlersen c1e7044561 Added samples for burst and entities 2024-11-17 12:48:48 +01:00
47 changed files with 1269 additions and 171 deletions

View file

@ -2,6 +2,60 @@
All notable changes to this project will be documented in this file.
## [1.11.4] - 2025-09-21
### Fixed
- Fixed issue, where changing DPI scaling on monitor would detach visual elements from toolbar and not reattach/rebuild
## [1.11.3] - 2025-05-11
### Changed
- Changed type lookup to use TypeCache, instead of iterating through all assemblies
## [1.11.2] - 2024-11-26
### Added
- Added "Include Build Scenes", when sorting scenes into sub-menu
## [1.11.1] - 2024-11-25
### Added
- Added context menu to time scale, so it is possible to reset slider to 1.0
## [1.11.0] - 2025-03-29
### 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
## [1.10.2] - 2024-11-25
### Fixed
- Fixed issue, where scene picker would not prompt about unsaved scene changes
## [1.10.1] - 2024-11-25
### Fixed
- Fixed issue, where scene picker settings wouldn't save, if removing a group element
## [1.10.0] - 2024-11-17
### Added
- Added samples for burst and entities
## [1.9.5] - 2024-07-18
### Fixed

View file

@ -4,7 +4,7 @@ using UnityEditor.Overlays;
namespace Module.NavigationTool.Editor.SceneViewToolbar
{
[Overlay(typeof(SceneView), "unity-custom-tool-handle-utility", "Custom/Tool Settings", true)]
[Overlay(typeof(SceneView), "unity-custom-tool-handle-utility", "Custom/Tool Settings")]
internal sealed class EditorSceneViewToolHandleOverlay : ToolbarOverlay
{
public EditorSceneViewToolHandleOverlay()

View file

@ -23,7 +23,7 @@ namespace Module.NavigationTool.Editor.Toolbar
EditorApplication.update -= OnEditorUpdate;
EditorApplication.update += OnEditorUpdate;
}
private static void OnEditorUpdate()
{
if (!IS_INITIALIZED)
@ -47,8 +47,8 @@ namespace Module.NavigationTool.Editor.Toolbar
DRAWERS[i].Update();
}
}
#if UNITY_2021_1_OR_NEWER
#if UNITY_2021_1_OR_NEWER
private static void OnUpdateElements(VisualElement leftAlign, VisualElement rightAlign)
{
const float HEIGHT = 22.0f;

View file

@ -0,0 +1,9 @@
namespace Module.NavigationTool.Editor.Toolbar
{
public enum ESceneGroupBehaviourType
{
LoadAsGroup,
SortAsGroup,
SortInSubmenuAsGroup
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 71206076ab694b109f3391c4f28bc506
timeCreated: 1743238963

View file

@ -8,7 +8,10 @@ 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();
}
}

View file

@ -24,7 +24,6 @@ namespace Module.NavigationTool.Editor.Toolbar
List<WorkingSetScene> assets = GetWorkingSet();
FetchAllScenesFromBuildSettings(assets);
FetchAllScenesFromLabels(assets, settings.labels);
FetchAllScenesFromSceneGroups(assets, settings.sceneGroups);
FetchAllRemainingScenes(assets);
@ -45,36 +44,14 @@ namespace Module.NavigationTool.Editor.Toolbar
{
name = asset.name,
shortname = asset.shortname,
paths = { asset.path }
paths = { asset.path },
inBuildSettings = true
});
}
}
private void FetchAllScenesFromLabels(List<WorkingSetScene> assets, List<string> labels)
{
List<WorkingSetScene> filteredScenes = GetAllWorkingSetScenesWithLabels(assets, labels);
filteredScenes = FilterToUniques(filteredScenes);
filteredScenes = FilterAllExcept(filteredScenes, scenes);
if (filteredScenes.Count != 0)
scenes.Add(new SceneElement{ includeAsSelectable = false });
for (var i = 0; i < filteredScenes.Count; i++)
{
scenes.Add(new SceneElement
{
name = filteredScenes[i].name,
shortname = filteredScenes[i].shortname,
paths = { filteredScenes[i].path }
});
}
}
private void FetchAllScenesFromSceneGroups(List<WorkingSetScene> assets, SceneGroupArray sceneGroups)
{
if (sceneGroups.Count != 0)
scenes.Add(new SceneElement{ includeAsSelectable = false });
for (var i = 0; i < sceneGroups.Count; i++)
{
SceneGroup sceneGroup = sceneGroups[i];
@ -95,28 +72,77 @@ namespace Module.NavigationTool.Editor.Toolbar
name = sceneGroup.name.Replace("/", "\\");
}
if (!string.IsNullOrEmpty(sceneGroup.optionalMainScenePath))
SetWorkingSceneAsFirst(filteredScenes, sceneGroup.optionalMainScenePath);
filteredScenes = FilterToUniques(filteredScenes);
var scene = new SceneElement
if (sceneGroup.behaviourType == ESceneGroupBehaviourType.LoadAsGroup)
{
name = name,
shortname = name,
isGroup = true
};
for (var j = 0; j < filteredScenes.Count; j++)
{
scene.paths.Add(filteredScenes[j].path);
if (sceneGroups.Count != 0)
scenes.Add(new SceneElement{ includeAsSelectable = false });
if (!string.IsNullOrEmpty(sceneGroup.optionalMainScenePath))
SetWorkingSceneAsFirst(filteredScenes, sceneGroup.optionalMainScenePath);
filteredScenes = FilterToUniques(filteredScenes);
var scene = new SceneElement
{
name = name,
shortname = name,
isGroup = true
};
for (var j = 0; j < filteredScenes.Count; j++)
{
scene.paths.Add(filteredScenes[j].path);
}
scene.name += $" ({scene.paths.Count})";
scenes.Add(scene);
}
else if (sceneGroup.behaviourType == ESceneGroupBehaviourType.SortAsGroup)
{
filteredScenes = FilterToUniques(filteredScenes);
filteredScenes = FilterAllExcept(filteredScenes, scenes);
if (filteredScenes.Count != 0)
scenes.Add(new SceneElement{ includeAsSelectable = false });
for (var j = 0; j < filteredScenes.Count; j++)
{
scenes.Add(new SceneElement
{
name = filteredScenes[j].name,
shortname = filteredScenes[j].shortname,
paths = { filteredScenes[j].path }
});
}
}
else if (sceneGroup.behaviourType == ESceneGroupBehaviourType.SortInSubmenuAsGroup)
{
if (string.IsNullOrEmpty(sceneGroup.subMenuPath))
continue;
filteredScenes = FilterToUniques(filteredScenes);
if (sceneGroup.includeBuildScenes)
filteredScenes = FilterAllExceptWithBuildScenes(filteredScenes, scenes);
else
filteredScenes = FilterAllExcept(filteredScenes, scenes);
if (filteredScenes.Count != 0)
scenes.Add(new SceneElement{ includeAsSelectable = false });
for (var j = 0; j < filteredScenes.Count; j++)
{
scenes.Add(new SceneElement
{
name = $"{sceneGroup.subMenuPath}/{filteredScenes[j].name}",
shortname = filteredScenes[j].shortname,
paths = { filteredScenes[j].path }
});
}
}
scene.name += $" ({scene.paths.Count})";
scenes.Add(scene);
}
}
private void FetchAllRemainingScenes(List<WorkingSetScene> assets)
{
List<WorkingSetScene> filteredScenes = FilterAllExcept(assets, scenes);
@ -174,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];
@ -374,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>();
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
namespace Module.NavigationTool.Editor.Toolbar
{
@ -8,8 +7,7 @@ namespace Module.NavigationTool.Editor.Toolbar
public string Title => "Scene";
public bool IsSettingsDirty { get; private set; }
private StringReordableListDrawer assetLabelList;
private SceneGroupReordableListDrawer sceneGroupList;
private SceneGroupReorderableListDrawer sceneGroupList;
private ToolbarProjectSettings projectSettings;
private Settings settings;
@ -19,18 +17,14 @@ namespace Module.NavigationTool.Editor.Toolbar
this.projectSettings = projectSettings;
settings = projectSettings.GetValueAs<Settings>();
assetLabelList = new StringReordableListDrawer(settings.labels, "Scene sorting by Asset label");
assetLabelList.onChanged += ToolScenePicker.SetAsDirty;
sceneGroupList = new SceneGroupReordableListDrawer(settings.sceneGroups.groups, "Scene groups");
sceneGroupList = new SceneGroupReorderableListDrawer(settings.sceneGroups.groups, "Scene groups");
sceneGroupList.onChanged += ToolScenePicker.SetAsDirty;
}
public void Draw()
{
assetLabelList.DoLayoutList();
sceneGroupList.DoLayoutList();
IsSettingsDirty = assetLabelList.IsDirty || sceneGroupList.IsDirty;
IsSettingsDirty = sceneGroupList.IsDirty;
}
public void SetSettingsValue()
@ -41,7 +35,6 @@ namespace Module.NavigationTool.Editor.Toolbar
[Serializable]
public sealed class Settings
{
public List<string> labels = new();
public SceneGroupArray sceneGroups = new();
}
}

View file

@ -1,7 +1,6 @@
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;
using UTools = UnityEditor.Tools;
namespace Module.NavigationTool.Editor.Toolbar
{

View file

@ -120,6 +120,9 @@ namespace Module.NavigationTool.Editor.Toolbar
{
try
{
if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
return;
ScenePickerList.SceneElement scenes = SCENE_LIST.scenes[index];
bool isScenePickerSetAsAdditive = ToolbarScenePickerSettings.IsScenePickerSetAsAdditive;
@ -223,7 +226,6 @@ namespace Module.NavigationTool.Editor.Toolbar
public static readonly GUIContent LABEL_SCENE_SINGLE = new GUIContent(string.Empty, "Single scene loading (toggle to Additive)");
#endif
public static readonly GUIContent LABEL_SCENE_CREATE = new GUIContent(string.Empty, "Create a new scene");
public const float BUTTON_WIDTH = 24.0f;
}

View file

@ -28,6 +28,16 @@ namespace Module.NavigationTool.Editor.Toolbar
EditorGUI.LabelField(r0, LABEL_TIME_SCALE, styles.centeredMiniLabel);
EditorGUI.LabelField(r2, LABEL_TIME_VALUE, styles.centeredMiniLabel);
if (Event.current.keyCode == KeyCode.Mouse1 && rect.Contains(Event.current.mousePosition))
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Reset"), false, () => Time.timeScale = 1f);
menu.ShowAsContext();
Event.current.Use();
}
float temp = GUI.HorizontalSlider(r1, value, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue);
temp = Mathf.Clamp(temp, ToolbarTimeSettings.TimeScaleMinValue, ToolbarTimeSettings.TimeScaleMaxValue);

View file

@ -6,7 +6,7 @@ using UnityEngine;
namespace Module.NavigationTool.Editor.Toolbar
{
internal abstract class AbstractReordableListDrawer<T>
internal abstract class AbstractReorderableListDrawer<T>
{
public readonly List<T> list;
@ -15,11 +15,11 @@ namespace Module.NavigationTool.Editor.Toolbar
public bool IsDirty { get; private set; }
protected AbstractReordableListDrawer(List<T> list, string header)
protected AbstractReorderableListDrawer(List<T> list, string header)
{
this.list = list;
reorderableList = new ReorderableList(list, typeof(string), true, true, true, true);
reorderableList = new ReorderableList(this.list, typeof(T), true, true, true, true);
reorderableList.drawElementCallback += (rect, index, isActive, isFocused) =>
{
EditorGUI.BeginChangeCheck();
@ -36,7 +36,7 @@ namespace Module.NavigationTool.Editor.Toolbar
};
reorderableList.onRemoveCallback += rl =>
{
list.RemoveAt(rl.index);
this.list.RemoveAt(rl.index);
OnRemovedElementFromList(rl.index);
InvokeChanged();
};
@ -70,6 +70,7 @@ namespace Module.NavigationTool.Editor.Toolbar
protected void InvokeChanged()
{
IsDirty = true;
onChanged?.Invoke();
}
}

View file

@ -1,81 +0,0 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Module.NavigationTool.Editor.Toolbar
{
internal sealed class SceneGroupReordableListDrawer : AbstractReordableListDrawer<SceneGroup>
{
private readonly List<StringReordableListDrawer> elements = new List<StringReordableListDrawer>();
public SceneGroupReordableListDrawer(List<SceneGroup> list, string header)
: base(list, header)
{
for (var i = 0; i < list.Count; i++)
{
elements.Add(new StringReordableListDrawer(list[i].filters, "Filters"));
}
}
protected override void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused)
{
rect.height -= 2;
rect.y += 1;
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);
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"))
{
string mainScenePath = EditorUtility.OpenFilePanel("Scene", "Assets", "unity");
if (!string.IsNullOrEmpty(mainScenePath))
{
mainScenePath = mainScenePath.Substring(Application.dataPath.Length - 6);
group.optionalMainScenePath = mainScenePath;
}
}
group.filterType = (ESceneGroupFilterType)EditorGUI.EnumPopup(rectType, "Filter Type", group.filterType);
elements[index].DoList(rectLabels);
if (EditorGUI.EndChangeCheck())
InvokeChanged();
}
protected override void OnAddElementToList()
{
var filters = new List<string>();
list.Add(new SceneGroup
{
name = "New Scene Group",
filters = filters
});
elements.Add(new StringReordableListDrawer(filters, "Filters"));
}
protected override void OnRemovedElementFromList(int index)
{
elements.RemoveAt(index);
}
protected override float OnElementHeight(int index)
{
int labelCount = list[index].filters.Count;
return base.OnElementHeight(index) * 3f
+ Mathf.Max(0, labelCount - 1) * (EditorGUIUtility.singleLineHeight + 2f)
+ 78f;
}
}
}

View file

@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Module.NavigationTool.Editor.Toolbar
{
internal sealed class SceneGroupReorderableListDrawer : AbstractReorderableListDrawer<SceneGroup>
{
private readonly List<StringReorderableListDrawer> elements = new List<StringReorderableListDrawer>();
public SceneGroupReorderableListDrawer(List<SceneGroup> list, string header)
: base(list, header)
{
for (var i = 0; i < list.Count; i++)
{
elements.Add(new StringReorderableListDrawer(list[i].filters, "Filters"));
}
}
protected override void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused)
{
rect.height -= 2;
rect.y += 1;
SceneGroup group = list[index];
var rectName = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
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);
if (group.behaviourType == ESceneGroupBehaviourType.LoadAsGroup)
{
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 (GUI.Button(rectOptionalBtn, "Find"))
{
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 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);
}
group.behaviourType = (ESceneGroupBehaviourType)EditorGUI.EnumPopup(rectBehaviourType, "Behaviour Type", group.behaviourType);
group.filterType = (ESceneGroupFilterType)EditorGUI.EnumPopup(rectType, "Filter Type", group.filterType);
elements[index].DoList(rectLabels);
if (EditorGUI.EndChangeCheck())
InvokeChanged();
}
protected override void OnAddElementToList()
{
var filters = new List<string>();
list.Add(new SceneGroup
{
name = "New Scene Group",
filters = filters
});
elements.Add(new StringReorderableListDrawer(filters, "Filters"));
}
protected override void OnRemovedElementFromList(int index)
{
elements.RemoveAt(index);
}
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)
+ extra;
}
}
}

View file

@ -5,9 +5,9 @@ using UnityEngine;
namespace Module.NavigationTool.Editor.Toolbar
{
internal sealed class StringReordableListDrawer : AbstractReordableListDrawer<string>
internal sealed class StringReorderableListDrawer : AbstractReorderableListDrawer<string>
{
public StringReordableListDrawer(List<string> list, string header)
public StringReorderableListDrawer(List<string> list, string header)
: base(list, header)
{
}

View file

@ -1,8 +1,13 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
#if UNITY_2021_3 || UNITY_2022_2 || UNITY_6000_0_OR_NEWER
using UnityEditor;
#else
using System.Reflection;
#endif
namespace Module.NavigationTool.Editor.Toolbar
{
internal static class ToolbarSettingsUtility
@ -13,6 +18,21 @@ namespace Module.NavigationTool.Editor.Toolbar
try
{
#if UNITY_2021_3 || UNITY_2022_2 || UNITY_6000_0_OR_NEWER
var types = TypeCache.GetTypesDerivedFrom<IToolbarSettings>();
for (var i = 0; i < types.Count; i++)
{
Type type = types[i];
if (type.IsInterface || type.IsAbstract)
continue;
var toolbar = (IToolbarSettings)FormatterServices.GetUninitializedObject(type);
toolbar.Initialize();
list.Add(toolbar);
}
#else
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Type iType = typeof(IToolbarSettings);
@ -33,6 +53,7 @@ namespace Module.NavigationTool.Editor.Toolbar
list.Add(toolbar);
}
}
#endif
list.Sort((s0, s1) => string.Compare(s0.Title, s1.Title, StringComparison.Ordinal));
}
@ -50,6 +71,21 @@ namespace Module.NavigationTool.Editor.Toolbar
try
{
#if UNITY_2021_3 || UNITY_2022_2 || UNITY_6000_0_OR_NEWER
var types = TypeCache.GetTypesDerivedFrom<IToolbarProjectSettings>();
for (var i = 0; i < types.Count; i++)
{
Type type = types[i];
if (type.IsInterface || type.IsAbstract)
continue;
var toolbar = (IToolbarProjectSettings)FormatterServices.GetUninitializedObject(type);
toolbar.Initialize(settings);
list.Add(toolbar);
}
#else
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Type iType = typeof(IToolbarProjectSettings);
@ -70,6 +106,7 @@ namespace Module.NavigationTool.Editor.Toolbar
list.Add(toolbar);
}
}
#endif
list.Sort((s0, s1) => string.Compare(s0.Title, s1.Title, StringComparison.Ordinal));
}

View file

@ -5,6 +5,10 @@ using System.Reflection;
using System.Runtime.Serialization;
using Object = UnityEngine.Object;
#if UNITY_2021_3 || UNITY_2022_2 || UNITY_6000_0_OR_NEWER
using UnityEditor;
#endif
#if UNITY_2019_1_OR_NEWER
using UnityEngine.UIElements;
#else
@ -17,25 +21,27 @@ namespace Module.NavigationTool.Editor.Toolbar
{
private static readonly Assembly ASSEMBLY = typeof(UnityEditor.Editor).Assembly;
#if UNITY_2021_1_OR_NEWER
#if UNITY_2021_1_OR_NEWER
private static ScriptableObject CURRENT_TOOLBAR;
private static VisualElement CURRENT_ROOT;
private static VisualElement CURRENT_PARENT_LEFT;
private static VisualElement CURRENT_PARENT_RIGHT;
private static int CURRENT_INSTANCE_ID = -1;
#endif
private static int CURRENT_INSTANCE_ID;
private static FieldInfo FIELD_INFO_ROOT;
#endif
#if UNITY_2021_1_OR_NEWER
#if UNITY_2021_1_OR_NEWER
public static void OnUpdate(Action<VisualElement, VisualElement> callback)
{
if (CURRENT_TOOLBAR == null)
CURRENT_TOOLBAR = GetToolbarObject();
if (CURRENT_TOOLBAR != null && CURRENT_PARENT_LEFT != null && CURRENT_TOOLBAR.GetInstanceID() != CURRENT_INSTANCE_ID)
if (CURRENT_TOOLBAR != null && CURRENT_TOOLBAR.GetInstanceID() != CURRENT_INSTANCE_ID)
{
CURRENT_PARENT_LEFT.RemoveFromHierarchy();
CURRENT_PARENT_LEFT?.RemoveFromHierarchy();
CURRENT_PARENT_LEFT = null;
CURRENT_PARENT_RIGHT.RemoveFromHierarchy();
CURRENT_PARENT_RIGHT?.RemoveFromHierarchy();
CURRENT_PARENT_RIGHT = null;
CURRENT_INSTANCE_ID = CURRENT_TOOLBAR.GetInstanceID();
@ -44,17 +50,27 @@ namespace Module.NavigationTool.Editor.Toolbar
if (CURRENT_TOOLBAR == null)
return;
if (CURRENT_PARENT_LEFT == null)
if (CURRENT_PARENT_LEFT == null || CURRENT_PARENT_RIGHT == null || CURRENT_ROOT == null)
{
CURRENT_INSTANCE_ID = CURRENT_TOOLBAR.GetInstanceID();
CURRENT_PARENT_LEFT?.RemoveFromHierarchy();
CURRENT_PARENT_LEFT = null;
CURRENT_PARENT_RIGHT?.RemoveFromHierarchy();
CURRENT_PARENT_RIGHT = null;
FieldInfo root = CURRENT_TOOLBAR.GetType().GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance);
object rawRoot = root?.GetValue(CURRENT_TOOLBAR);
var mRoot = rawRoot as VisualElement;
CURRENT_PARENT_LEFT = CreateParent(mRoot, "ToolbarZoneLeftAlign", true);
CURRENT_PARENT_RIGHT = CreateParent(mRoot, "ToolbarZoneRightAlign", false);
if (FIELD_INFO_ROOT == null)
FIELD_INFO_ROOT = CURRENT_TOOLBAR.GetType().GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance);
object rawRoot = FIELD_INFO_ROOT?.GetValue(CURRENT_TOOLBAR);
CURRENT_ROOT = rawRoot as VisualElement;
if (CURRENT_ROOT != null)
{
CURRENT_PARENT_LEFT = CreateParent(CURRENT_ROOT, "ToolbarZoneLeftAlign", true);
CURRENT_PARENT_RIGHT = CreateParent(CURRENT_ROOT, "ToolbarZoneRightAlign", false);
}
}
if (CURRENT_PARENT_LEFT != null)
@ -108,10 +124,14 @@ namespace Module.NavigationTool.Editor.Toolbar
});
}
#if UNITY_6000_0_OR_NEWER
result.RegisterCallbackOnce<DetachFromPanelEvent>(OnDetachedFromPanel);
#endif
parent.Add(result);
return result;
}
#else
#else
public static void AddGuiListener(Action action)
{
ScriptableObject so = GetToolbarObject();
@ -153,7 +173,7 @@ namespace Module.NavigationTool.Editor.Toolbar
handler += action;
fiImguiContainer.SetValue(container, handler);
}
#endif
#endif
private static ScriptableObject GetToolbarObject()
{
@ -168,6 +188,17 @@ namespace Module.NavigationTool.Editor.Toolbar
try
{
#if UNITY_2021_3 || UNITY_2022_2 || UNITY_6000_0_OR_NEWER
var types = TypeCache.GetTypesDerivedFrom<AbstractToolbarDrawer>();
for (var i = 0; i < types.Count; i++)
{
Type type = types[i];
if (!type.IsAbstract)
list.Add((AbstractToolbarDrawer)FormatterServices.GetUninitializedObject(type));
}
#else
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Type iType = typeof(AbstractToolbarDrawer);
@ -184,6 +215,7 @@ namespace Module.NavigationTool.Editor.Toolbar
list.Add((AbstractToolbarDrawer)FormatterServices.GetUninitializedObject(type));
}
}
#endif
list.Sort((t0, t1) => t0.Priority.CompareTo(t1.Priority));
}
@ -194,5 +226,12 @@ namespace Module.NavigationTool.Editor.Toolbar
return list.ToArray();
}
#if UNITY_6000_0_OR_NEWER
private static void OnDetachedFromPanel(DetachFromPanelEvent evt)
{
CURRENT_INSTANCE_ID = -1;
}
#endif
}
}

9
LICENSE Normal file
View file

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2025 ejlersen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

7
LICENSE.meta Normal file
View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 81eaa9f1644b27547b1195ceb554d6b9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -22,12 +22,15 @@ Toolbars to the left and right of the play-buttons. Anything can be added, as lo
Several tools are available from start:
* UI Layer: Toggle the UI layer on/off
* UI Canvas: Select and center the camera on any Canvases in the scene
* Scene: Load any scene in the project easily by using the dropdown
* Time Scale: Adjust the time scale from [0;1] from a slider
* Target Frame Rate Scale: Adjust target frame rate from [10;144] from a slider
* Build: Select build target and build
* Player Prefs: Delete all PlayerPrefs data
* Scene: Load any scene in the project easily by using the dropdown
* Target Frame Rate Scale: Adjust target frame rate from [10;144] from a slider
* Time Scale: Adjust the time scale from [0;1] from a slider
* UI Canvas: Select and center the camera on any Canvases in the scene
* UI Layer: Toggle the UI layer on/off
* Settings: Open project or preferences
* Save: Project save
### Customization

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e31d016aae6230944a6f391781dec340
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,117 @@
fileFormatVersion: 2
guid: 60fb1efbdd5470143ad7d05f4789d734
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1,117 @@
fileFormatVersion: 2
guid: 11a0ecf430044e34da03a9f55d260972
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1,117 @@
fileFormatVersion: 2
guid: 919dde4918f9c2040ae36996a59f7fda
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,117 @@
fileFormatVersion: 2
guid: aa74587cda5d7cd4881de734449f86c6
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,18 @@
{
"name": "Module.NavigationTool.Editor.Burst",
"rootNamespace": "Module.NavigationTool.Editor.Burst",
"references": [
"GUID:8339b3ce77cb32f489776d81010ad36c"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3c2c8e14dde10d149b8c2675bddde058
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9515ea51d438d864bb613126b10ff5fe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,27 @@
using Module.NavigationTool.Editor.Toolbar;
using UnityEditor;
namespace Module.NavigationTool.Editor.Burst.Toolbar
{
internal sealed class ToolbarBurstSettings : IToolbarSettings
{
public string Title => "Burst";
private const string PREF_PREFS_ENABLED = "ToolbarSettings.IsBurstsEnabled";
public static bool IsEnabled
{
get => EditorPrefs.GetBool(PREF_PREFS_ENABLED, false);
set => EditorPrefs.SetBool(PREF_PREFS_ENABLED, value);
}
public void Initialize()
{
}
public void Draw()
{
IsEnabled = EditorGUILayout.Toggle("Enable Burst", IsEnabled);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1b064274e467ceb4c876833f7fef3ec2

View file

@ -0,0 +1,98 @@
using System;
using System.Reflection;
using JetBrains.Annotations;
using Module.NavigationTool.Editor.Toolbar;
using UnityEditor;
using UnityEditor.Profiling;
using UnityEngine;
namespace Module.NavigationTool.Editor.Burst.Toolbar
{
[UsedImplicitly]
internal sealed class ToolBurst : AbstractToolbarDrawer
{
public override bool Visible => ToolbarBurstSettings.IsEnabled;
public override bool Enabled => true;
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
public override int Priority => (int)EToolbarPriority.Low;
protected override void Draw(Rect rect)
{
Styles.Initialize();
if (GUI.Button(rect, IsBurstEnabled() ? Styles.ICON_ENABLED : Styles.ICON_DISABLED, styles.button))
EditorApplication.ExecuteMenuItem("Jobs/Burst/Enable Compilation");
GUI.Label(rect, Styles.LABEL, styles.labelCenter);
}
public override float CalculateWidth()
{
return 24.0f;
}
private bool IsBurstEnabled()
{
const string typeFullname = "Unity.Burst.Editor.BurstEditorOptions, Unity.Burst";
const string propertyName = "EnableBurstCompilation";
var type = Type.GetType(typeFullname, false, true);
if (type == null)
{
Debug.LogWarningFormat("Failed to find type with name: {0}", typeFullname);
return false;
}
PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Static);
if (property == null)
{
Debug.LogWarningFormat("Failed to find property with name: {0} on type: {1}", propertyName, typeFullname);
return false;
}
return (bool)property.GetValue(null);
}
private static class Styles
{
public static readonly GUIContent LABEL = new GUIContent(string.Empty, "Enable/disable burst compiler");
public static GUIContent ICON_ENABLED;
public static GUIContent ICON_DISABLED;
private static bool IS_INITIALIZED;
private const string EditorIconFileNameLight = "tex_icon_burst_light";
private const string EditorIconFileNameDark = "tex_icon_burst_dark";
public static void Initialize()
{
if (IS_INITIALIZED)
return;
ICON_ENABLED = new GUIContent(LoadIcon("_enabled"));
ICON_DISABLED = new GUIContent(LoadIcon("_disabled"));
IS_INITIALIZED = true;
}
private static Texture2D LoadIcon(string postfix)
{
string iconPrefix = EditorGUIUtility.isProSkin ? EditorIconFileNameDark : EditorIconFileNameLight;
string filename = $"{iconPrefix}{postfix}";
string[] guids = AssetDatabase.FindAssets("t:texture " + filename);
for (int i = 0; i < guids.Length; i++)
{
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
Texture2D tex = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
if (tex != null)
return tex;
}
return null;
}
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 12286d5e95c428b4894a8d88b86b8080

View file

@ -0,0 +1,18 @@
{
"name": "Module.NavigationTool.Editor.Entities",
"rootNamespace": "Module.NavigationTool.Editor.Entities",
"references": [
"GUID:8339b3ce77cb32f489776d81010ad36c"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7f005006296b7aa41b589cd21e890d5c
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b746b07b87c4e4340aed5ad6a7bc3b64
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,27 @@
using Module.NavigationTool.Editor.Toolbar;
using UnityEditor;
namespace Module.NavigationTool.Editor.Entities.Toolbar
{
internal sealed class ToolbarEntitiesSettings : IToolbarSettings
{
public string Title => "Entities";
private const string PREF_PREFS_ENABLED = "ToolbarSettings.IsEntitiesEnabled";
public static bool IsEnabled
{
get => EditorPrefs.GetBool(PREF_PREFS_ENABLED, false);
set => EditorPrefs.SetBool(PREF_PREFS_ENABLED, value);
}
public void Initialize()
{
}
public void Draw()
{
IsEnabled = EditorGUILayout.Toggle("Enable Entities", IsEnabled);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1077d6399eff29247a55c20578a2df1c

View file

@ -0,0 +1,125 @@
using System;
using JetBrains.Annotations;
using Module.NavigationTool.Editor.Toolbar;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Module.NavigationTool.Editor.Entities.Toolbar
{
[UsedImplicitly]
internal sealed class ToolEntities : AbstractToolbarDrawer
{
public override bool Visible => ToolbarEntitiesSettings.IsEnabled;
public override bool Enabled => true;
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
public override int Priority => (int)EToolbarPriority.Low;
protected override void Draw(Rect rect)
{
Styles.Initialize();
Rect rect0 = new Rect(rect.x, rect.y, 24f, rect.height);
Rect rect1 = new Rect(rect0.xMax, rect.y, 24f, rect.height);
Rect rect2 = new Rect(rect1.xMax, rect.y, 24f, rect.height);
Rect rect3 = new Rect(rect2.xMax, rect.y, 24f, rect.height);
Rect rect4 = new Rect(rect3.xMax, rect.y, 24f, rect.height);
if (GUI.Button(rect0, Styles.ICON_HIERARCHY, styles.button))
ToggleWindow("HierarchyWindow");
if (GUI.Button(rect1, Styles.ICON_COMPONENTS, styles.button))
ToggleWindow("ComponentsWindow");
if (GUI.Button(rect2, Styles.ICON_SYSTEMS, styles.button))
ToggleWindow("SystemScheduleWindow");
if (GUI.Button(rect3, Styles.ICON_ARCHETYPES, styles.button))
ToggleWindow("ArchetypesWindow");
if (GUI.Button(rect4, Styles.ICON_JOURNALING, styles.button))
ToggleWindow("EntitiesJournalingWindow");
GUI.Label(rect0, Styles.LABEL_HIERARCHY, styles.labelCenter);
GUI.Label(rect1, Styles.LABEL_COMPONENTS, styles.labelCenter);
GUI.Label(rect2, Styles.LABEL_SYSTEMS, styles.labelCenter);
GUI.Label(rect3, Styles.LABEL_ARCHETYPES, styles.labelCenter);
GUI.Label(rect4, Styles.LABEL_JOURNALING, styles.labelCenter);
}
public override float CalculateWidth()
{
return 120.0f;
}
private void ToggleWindow(string typeName)
{
string fullname = "Unity.Entities.Editor." + typeName + ", Unity.Entities.Editor";
Type type = Type.GetType(fullname, false, true);
if (type != null)
{
Object[] all = Resources.FindObjectsOfTypeAll(type);
if (all.Length != 0)
{
for (int i = 0; i < all.Length; i++)
{
if (all[i] is EditorWindow window)
window.Close();
}
}
else
{
EditorWindow.GetWindow(type);
}
}
else
{
Debug.LogWarningFormat("Failed to find type with name: {0}", fullname);
}
}
private static class Styles
{
public static readonly GUIContent LABEL_HIERARCHY = new GUIContent(string.Empty, "Show/Hide entities hierarchy window");
public static readonly GUIContent LABEL_COMPONENTS = new GUIContent(string.Empty, "Show/Hide entities components window");
public static readonly GUIContent LABEL_SYSTEMS = new GUIContent(string.Empty, "Show/Hide entities systems window");
public static readonly GUIContent LABEL_ARCHETYPES = new GUIContent(string.Empty, "Show/Hide entities archetypes window");
public static readonly GUIContent LABEL_JOURNALING = new GUIContent(string.Empty, "Show/Hide entities journaling window");
public static GUIContent ICON_HIERARCHY;
public static GUIContent ICON_COMPONENTS;
public static GUIContent ICON_SYSTEMS;
public static GUIContent ICON_ARCHETYPES;
public static GUIContent ICON_JOURNALING;
private static bool IS_INITIALIZED;
private const string EditorDefaultResourcesPath = "Packages/com.unity.entities/Editor Default Resources/";
private const string EditorIconsLightDirectory = EditorDefaultResourcesPath + "icons/light";
private const string EditorIconsDarkDirectory = EditorDefaultResourcesPath + "icons/dark";
public static void Initialize()
{
if (IS_INITIALIZED)
return;
ICON_HIERARCHY = new GUIContent(LoadIcon("EntityGroup/EntityGroup"));
ICON_COMPONENTS = new GUIContent(LoadIcon("Component/Component"));
ICON_SYSTEMS = new GUIContent(LoadIcon("System/System"));
ICON_ARCHETYPES = new GUIContent(LoadIcon("Archetype/Archetype"));
ICON_JOURNALING = new GUIContent(LoadIcon("Journaling/Journaling"));
IS_INITIALIZED = true;
}
private static Texture2D LoadIcon(string name)
{
string iconsDirectory = EditorIconsLightDirectory;
if (EditorGUIUtility.isProSkin)
iconsDirectory = EditorIconsDarkDirectory;
Object obj = AssetDatabase.LoadAssetAtPath(iconsDirectory + "/" + name + ".png", typeof(Texture2D));
return obj != null ? (Texture2D)obj : null;
}
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 460de731a77f02347b6ae7d35050a5f1

View file

@ -1,6 +1,6 @@
{
"name": "com.module.navigationtool",
"version": "1.9.5",
"version": "1.11.4",
"displayName": "Module.NavigationTool",
"description": "Support for navigation tools, like favorites, history and toolbars",
"unity": "2019.2",
@ -19,5 +19,16 @@
"email": "anders@ejlersen.info",
"url": "https://www.ejlersen.info"
},
"_fingerprint": "06420f1ad404ea844ae5d2f3a0a3f841703632f5"
"samples": [
{
"displayName": "Entities Toolbar Sample",
"description": "Displays a list of five buttons for show/hiding hierarchy, components, systems, archetypes and journaling window",
"path": "Samples~/SamplesToolbarEntities"
},
{
"displayName": "Burst Toolbar Sample",
"description": "Displays a enable/disable burst compiler button",
"path": "Samples~/SamplesToolbarBurst"
}
]
}