1.6.0: Added a tool position and rotation scene view toolbar menu which uses buttons, instead of toggle drop down menu
This commit is contained in:
parent
faf964ac93
commit
d9e62f6589
3
Editor/SceneView.meta
Normal file
3
Editor/SceneView.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 028316b5da4e417bb514260047ab5989
|
||||||
|
timeCreated: 1658768591
|
||||||
16
Editor/SceneView/EditorSceneViewToolHandleOverlay.cs
Normal file
16
Editor/SceneView/EditorSceneViewToolHandleOverlay.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#if UNITY_2021_1_OR_NEWER
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.Overlays;
|
||||||
|
|
||||||
|
namespace Module.NavigationTool.Editor.SceneViewToolbar
|
||||||
|
{
|
||||||
|
[Overlay(typeof(SceneView), "unity-custom-tool-handle-utility", "Custom/Tool Settings", true)]
|
||||||
|
internal sealed class EditorSceneViewToolHandleOverlay : ToolbarOverlay
|
||||||
|
{
|
||||||
|
public EditorSceneViewToolHandleOverlay()
|
||||||
|
: base("SceneView/Custom/HandlePosition", "SceneView/Custom/HandleRotation")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7b94bff7197641bfb17797d5e3a685e5
|
||||||
|
timeCreated: 1658768617
|
||||||
44
Editor/SceneView/EditorSceneViewToolHandlePosition.cs
Normal file
44
Editor/SceneView/EditorSceneViewToolHandlePosition.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#if UNITY_2021_1_OR_NEWER
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.Toolbars;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Module.NavigationTool.Editor.SceneViewToolbar
|
||||||
|
{
|
||||||
|
[EditorToolbarElement("SceneView/Custom/HandlePosition", typeof(SceneView))]
|
||||||
|
internal sealed class EditorSceneViewToolHandlePosition : EditorToolbarButton
|
||||||
|
{
|
||||||
|
public EditorSceneViewToolHandlePosition()
|
||||||
|
{
|
||||||
|
tooltip = "Toggle Tool Handle Position\nThe tool handle is placed at the active object's pivot point.";
|
||||||
|
clicked += OnClicked;
|
||||||
|
|
||||||
|
RefreshIcon();
|
||||||
|
Tools.pivotModeChanged += OnPivotModeChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
~EditorSceneViewToolHandlePosition()
|
||||||
|
{
|
||||||
|
Tools.pivotModeChanged -= OnPivotModeChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshIcon()
|
||||||
|
{
|
||||||
|
if (Tools.pivotMode == PivotMode.Center)
|
||||||
|
icon = EditorGUIUtility.IconContent("d_ToolHandleCenter").image as Texture2D;
|
||||||
|
else
|
||||||
|
icon = EditorGUIUtility.IconContent("d_ToolHandlePivot").image as Texture2D;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClicked()
|
||||||
|
{
|
||||||
|
Tools.pivotMode = Tools.pivotMode == PivotMode.Center ? PivotMode.Pivot : PivotMode.Center;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPivotModeChanged()
|
||||||
|
{
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b88e5d3205024d6da608ef18f4f46225
|
||||||
|
timeCreated: 1658778834
|
||||||
44
Editor/SceneView/EditorSceneViewToolHandleRotation.cs
Normal file
44
Editor/SceneView/EditorSceneViewToolHandleRotation.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#if UNITY_2021_1_OR_NEWER
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.Toolbars;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Module.NavigationTool.Editor.SceneViewToolbar
|
||||||
|
{
|
||||||
|
[EditorToolbarElement("SceneView/Custom/HandleRotation", typeof(SceneView))]
|
||||||
|
internal sealed class EditorSceneViewToolHandleRotation : EditorToolbarButton
|
||||||
|
{
|
||||||
|
public EditorSceneViewToolHandleRotation()
|
||||||
|
{
|
||||||
|
tooltip = "Toggle Tool Handle Rotation\nTool handles are in the active object's rotation.";
|
||||||
|
clicked += OnClicked;
|
||||||
|
|
||||||
|
RefreshIcon();
|
||||||
|
Tools.pivotRotationChanged += OnPivotRotationChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
~EditorSceneViewToolHandleRotation()
|
||||||
|
{
|
||||||
|
Tools.pivotRotationChanged -= OnPivotRotationChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshIcon()
|
||||||
|
{
|
||||||
|
if (Tools.pivotRotation == PivotRotation.Global)
|
||||||
|
icon = EditorGUIUtility.IconContent("d_ToolHandleGlobal").image as Texture2D;
|
||||||
|
else
|
||||||
|
icon = EditorGUIUtility.IconContent("d_ToolHandleLocal").image as Texture2D;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClicked()
|
||||||
|
{
|
||||||
|
Tools.pivotRotation = Tools.pivotRotation == PivotRotation.Local ? PivotRotation.Global : PivotRotation.Local;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPivotRotationChanged()
|
||||||
|
{
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 42aa2d22dd9840e7abf9ef3bdf457634
|
||||||
|
timeCreated: 1658778874
|
||||||
|
|
@ -47,7 +47,7 @@ internal sealed class MyCustomTool : AbstractToolbarDrawer
|
||||||
|
|
||||||
public override float CalculateWidth()
|
public override float CalculateWidth()
|
||||||
{
|
{
|
||||||
// Default height for toolbar buttons is 30
|
// Default width for toolbar buttons is 30
|
||||||
return 30.0f;
|
return 30.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.module.navigationtool",
|
"name": "com.module.navigationtool",
|
||||||
"version": "1.5.2",
|
"version": "1.6.0",
|
||||||
"displayName": "Module.NavigationTool",
|
"displayName": "Module.NavigationTool",
|
||||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||||
"unity": "2019.2",
|
"unity": "2019.2",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue