1.1.0: Added README and ToolbarSettings, so visibility of tools can be set in Preferences -> Module -> Toolbar
This commit is contained in:
parent
e1d2deb4c5
commit
9802f8aaa3
23 changed files with 297 additions and 43 deletions
|
|
@ -9,7 +9,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
public GUIStyle slider;
|
||||
public GUIStyle label;
|
||||
public GUIStyle labelCenter;
|
||||
|
||||
public GUIStyle settingsGroup;
|
||||
private GUISkin skin;
|
||||
|
||||
public void Initialize(GUISkin skin)
|
||||
|
|
@ -24,6 +24,10 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
label = skin.FindStyle("ToolbarLabel");
|
||||
labelCenter = skin.FindStyle("ToolbarLabel");
|
||||
labelCenter.alignment = TextAnchor.MiddleCenter;
|
||||
settingsGroup = new GUIStyle
|
||||
{
|
||||
margin = new RectOffset(8, 0, 8, 0)
|
||||
};
|
||||
|
||||
// Available: ToolbarBoldLabel, ToolbarBottom, ToolbarButtonLeft, ToolbarButtonRight, ToolbarDropDown,
|
||||
// ToolbarLabel, ToolbarTextField, ...
|
||||
|
|
|
|||
16
Editor/Toolbar/Utilities/ToolbarIMGUIContainer.cs
Normal file
16
Editor/Toolbar/Utilities/ToolbarIMGUIContainer.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal sealed class ToolbarIMGUIContainer : IMGUIContainer
|
||||
{
|
||||
public int Priority { get; }
|
||||
|
||||
public ToolbarIMGUIContainer(Action onGuiHandler, int priority)
|
||||
: base(onGuiHandler)
|
||||
{
|
||||
Priority = priority;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Toolbar/Utilities/ToolbarIMGUIContainer.cs.meta
Normal file
3
Editor/Toolbar/Utilities/ToolbarIMGUIContainer.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 33569aa7bb974bd19b2208063bd64e95
|
||||
timeCreated: 1639929711
|
||||
|
|
@ -41,21 +41,26 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
CURRENT_INSTANCE_ID = CURRENT_TOOLBAR.GetInstanceID();
|
||||
}
|
||||
|
||||
if (CURRENT_TOOLBAR == null || CURRENT_PARENT_LEFT != null)
|
||||
if (CURRENT_TOOLBAR == null)
|
||||
return;
|
||||
|
||||
CURRENT_PARENT_LEFT?.RemoveFromHierarchy();
|
||||
CURRENT_PARENT_RIGHT?.RemoveFromHierarchy();
|
||||
if (CURRENT_PARENT_LEFT == null)
|
||||
{
|
||||
CURRENT_PARENT_LEFT?.RemoveFromHierarchy();
|
||||
CURRENT_PARENT_RIGHT?.RemoveFromHierarchy();
|
||||
|
||||
FieldInfo root = CURRENT_TOOLBAR.GetType().GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
object rawRoot = root?.GetValue(CURRENT_TOOLBAR);
|
||||
var mRoot = rawRoot as VisualElement;
|
||||
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);
|
||||
callback?.Invoke(CURRENT_PARENT_LEFT, CURRENT_PARENT_RIGHT);
|
||||
CURRENT_PARENT_LEFT = CreateParent(mRoot, "ToolbarZoneLeftAlign", true);
|
||||
CURRENT_PARENT_RIGHT = CreateParent(mRoot, "ToolbarZoneRightAlign", false);
|
||||
}
|
||||
|
||||
if (CURRENT_PARENT_LEFT != null)
|
||||
callback?.Invoke(CURRENT_PARENT_LEFT, CURRENT_PARENT_RIGHT);
|
||||
}
|
||||
|
||||
|
||||
private static VisualElement CreateParent(VisualElement root, string query, bool isLeft)
|
||||
{
|
||||
VisualElement parent = root.Q(query);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue