using System;
using UnityEngine;
using UnityEngine.ProBuilder;
using ToolManager = UnityEditor.EditorTools.ToolManager;
namespace UnityEditor.ProBuilder.Actions
{
///
/// Represents the [Cut tool](../manual/cut-tool.html) button on the [ProBuilder toolbar](../manual/toolbar.html) in the Editor.
///
public class CutToolAction : MenuAction
{
///
public override ToolbarGroup group
{
get { return ToolbarGroup.Tool; }
}
///
public override string iconPath => "Toolbar/CutTool";
///
public override Texture2D icon => IconUtility.GetIcon(iconPath);
///
public override TooltipContent tooltip
{
get { return s_Tooltip; }
}
///
public override SelectMode validSelectModes
{
get { return SelectMode.Vertex | SelectMode.Edge | SelectMode.Face; }
}
///
protected internal override bool hasFileMenuEntry
{
get { return false; }
}
static readonly TooltipContent s_Tooltip = new TooltipContent
(
"Cut Tool",
@"Create a cut in a face to subdivide it.",
keyCommandAlt, keyCommandShift, 'C'
);
///
public override bool enabled
{
get => MeshSelection.selectedObjectCount == 1;
}
///
protected override ActionResult PerformActionImplementation()
{
if(ToolManager.activeToolType == typeof(CutTool))
ToolManager.RestorePreviousTool();
else
ToolManager.SetActiveTool();
//Give the focus back to scene view to handle key inputs directly
SceneView.lastActiveSceneView.Focus();
return new ActionResult(ActionResult.Status.Success,"Cut Tool Starts");
}
}
}