1.7.0: Added option to sort scenes by asset labels
This commit is contained in:
parent
d9e62f6589
commit
cceef7bb7e
9 changed files with 136 additions and 21 deletions
|
|
@ -20,7 +20,11 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
get => EditorPrefs.GetBool(PREF_IS_BUILD_AND_RUN_ENABLED, true);
|
||||
set => EditorPrefs.SetBool(PREF_IS_BUILD_AND_RUN_ENABLED, value);
|
||||
}
|
||||
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsBuildEnabled = EditorGUILayout.Toggle("Enable Build Target picker", IsBuildEnabled);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
using UnityEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
|
|
@ -7,16 +12,80 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
public string Title => "Scene";
|
||||
|
||||
private const string PREF_IS_SCENE_ENABLED = "ToolbarSettings_IsSceneEnabled";
|
||||
private const string PREF_SCENE_ASSET_LABELS = "ToolbarSettings_SceneAssetLabels";
|
||||
|
||||
public static bool IsSceneEnabled
|
||||
{
|
||||
get => EditorPrefs.GetBool(PREF_IS_SCENE_ENABLED, true);
|
||||
set => EditorPrefs.SetBool(PREF_IS_SCENE_ENABLED, value);
|
||||
private set => EditorPrefs.SetBool(PREF_IS_SCENE_ENABLED, value);
|
||||
}
|
||||
|
||||
public static List<string> SceneAssetLabels
|
||||
{
|
||||
get => EditorPrefs.GetString(PREF_SCENE_ASSET_LABELS).Split(',').ToList();
|
||||
private set => EditorPrefs.SetString(PREF_SCENE_ASSET_LABELS, string.Join(',', value));
|
||||
}
|
||||
|
||||
private ReorderableList assetLabelList;
|
||||
private List<string> assetLabels;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
assetLabels = SceneAssetLabels.ToList();
|
||||
assetLabelList = new ReorderableList(assetLabels, typeof(string), true, true, true, true);
|
||||
assetLabelList.drawElementCallback += OnAssetLabelListDrawElement;
|
||||
assetLabelList.drawHeaderCallback += OnAssetLabelListDrawHeader;
|
||||
assetLabelList.onAddCallback += OnAssetLabelListAddedElement;
|
||||
assetLabelList.onRemoveCallback += OnAssetLabelListRemovedElement;
|
||||
assetLabelList.onReorderCallback += OnAssetLabelListReorder;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsSceneEnabled = EditorGUILayout.Toggle("Enable Scene picker", IsSceneEnabled);
|
||||
|
||||
if (assetLabelList == null)
|
||||
return;
|
||||
|
||||
assetLabelList.DoLayoutList();
|
||||
SceneAssetLabels = assetLabels;
|
||||
}
|
||||
|
||||
private static void OnAssetLabelListDrawHeader(Rect rect)
|
||||
{
|
||||
EditorGUI.LabelField(rect, "Scene sorting by Asset label");
|
||||
}
|
||||
|
||||
private void OnAssetLabelListDrawElement(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
rect.height -= 2;
|
||||
rect.y += 1;
|
||||
|
||||
string text = assetLabels[index];
|
||||
string temp = EditorGUI.TextField(rect, text);
|
||||
|
||||
if (string.Equals(text, temp, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
assetLabels[index] = temp;
|
||||
ToolScenePicker.SetAsDirty();
|
||||
}
|
||||
|
||||
private void OnAssetLabelListAddedElement(ReorderableList list)
|
||||
{
|
||||
assetLabels.Add(string.Empty);
|
||||
ToolScenePicker.SetAsDirty();
|
||||
}
|
||||
|
||||
private void OnAssetLabelListRemovedElement(ReorderableList list)
|
||||
{
|
||||
assetLabels.RemoveAt(list.index);
|
||||
ToolScenePicker.SetAsDirty();
|
||||
}
|
||||
|
||||
private void OnAssetLabelListReorder(ReorderableList list)
|
||||
{
|
||||
ToolScenePicker.SetAsDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
set => EditorPrefs.SetFloat(PREF_TIME_SCALE_MAX, value);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsTimeScaleEnabled = EditorGUILayout.Toggle("Enable Time Scale slider", IsTimeScaleEnabled);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
set => EditorPrefs.SetBool(PREF_IS_UI_LAYER_ENABLED, value);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
IsUiEnabled = EditorGUILayout.Toggle("Enable Canvas picker", IsUiEnabled);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue