Added RelayNodeView;
Chnaged GraphView to multiple files for better organization;
This commit is contained in:
45
Editor/Views/GraphView/GraphView_ContextualMenu.cs
Normal file
45
Editor/Views/GraphView/GraphView_ContextualMenu.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Misaki.GraphView.Editor
|
||||
{
|
||||
public partial class GraphView
|
||||
{
|
||||
public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
|
||||
{
|
||||
base.BuildContextualMenu(evt);
|
||||
var mousePosition = (evt.currentTarget as VisualElement).ChangeCoordinatesTo(contentViewContainer, evt.localMousePosition);
|
||||
|
||||
if (evt.target is GraphView)
|
||||
{
|
||||
evt.menu.InsertAction(1, "Create Sticky Note", e =>
|
||||
{
|
||||
var stickyNote = new StickyNoteData
|
||||
{
|
||||
title = "Sticky Note",
|
||||
contents = "Contents",
|
||||
theme = StickyNoteTheme.Classic,
|
||||
fontSize = StickyNoteFontSize.Medium,
|
||||
position = new Rect(mousePosition, new Vector2(200, 200))
|
||||
};
|
||||
|
||||
AddStickyNote(stickyNote);
|
||||
}, DropdownMenuAction.AlwaysEnabled);
|
||||
}
|
||||
|
||||
if (evt.target is Edge)
|
||||
{
|
||||
evt.menu.AppendAction("Create Relay Node", e =>
|
||||
{
|
||||
var relayNode = new RelayNode
|
||||
{
|
||||
position = new Rect(mousePosition, Vector2.zero)
|
||||
};
|
||||
|
||||
AddRelayNode(relayNode);
|
||||
}, DropdownMenuAction.AlwaysEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user