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
9 changed files with 118 additions and 2 deletions
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue