This repository has been archived by the owner on Oct 13, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lay the groundwork for - drag port to connect to new node
- Loading branch information
Kyle Rockman
committed
Jan 3, 2021
1 parent
0f48259
commit 14a26a9
Showing
14 changed files
with
131 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#if ODIN_INSPECTOR | ||
using System.Collections.Generic; | ||
using RedOwl.Sleipnir.Engine; | ||
using Sirenix.OdinInspector.Editor; | ||
|
||
namespace RedOwl.Sleipnir.Editor | ||
{ | ||
public class GraphNodePropertyProcessor<T> : OdinPropertyProcessor<T> where T : INode | ||
{ | ||
public override void ProcessMemberProperties(List<InspectorPropertyInfo> propertyInfos) | ||
{ | ||
var match = typeof(Port); | ||
for (int i = propertyInfos.Count - 1; i >= 0; i--) | ||
{ | ||
var info = propertyInfos[i]; | ||
if (match.IsAssignableFrom(info.TypeOfValue)) propertyInfos.RemoveAt(i); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using UnityEditor.Experimental.GraphView; | ||
using UnityEngine; | ||
using PortView = UnityEditor.Experimental.GraphView.Port; | ||
|
||
namespace RedOwl.Sleipnir.Editor | ||
{ | ||
/// <summary> | ||
/// Custom connector listener so that we can link up nodes and | ||
/// open a search box when the user drops an edge into the canvas | ||
/// </summary> | ||
public class SleipnirGraphEdgeConnectorListener : IEdgeConnectorListener | ||
{ | ||
private SleipnirGraphView view; | ||
|
||
public SleipnirGraphEdgeConnectorListener(SleipnirGraphView view) | ||
{ | ||
this.view = view; | ||
} | ||
|
||
/// <summary> | ||
/// Handle connecting nodes when an edge is dropped between two ports | ||
/// </summary> | ||
public void OnDrop(GraphView graphView, Edge edge) | ||
{ | ||
view.AddElement(edge); | ||
} | ||
|
||
/// <summary> | ||
/// Activate the search dialog when an edge is dropped on an arbitrary location | ||
/// </summary> | ||
public void OnDropOutsidePort(Edge edge, Vector2 position) | ||
{ | ||
var screenPosition = GUIUtility.GUIToScreenPoint( | ||
Event.current.mousePosition | ||
); | ||
|
||
if (edge.output != null) | ||
{ | ||
view.OpenSearch( | ||
screenPosition, | ||
edge.output.edgeConnector.edgeDragHelper.draggedPort as PortView | ||
); | ||
} | ||
else if (edge.input != null) | ||
{ | ||
view.OpenSearch( | ||
screenPosition, | ||
edge.input.edgeConnector.edgeDragHelper.draggedPort as PortView | ||
); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using RedOwl.Sleipnir.Engine; | ||
using UnityEditor.Experimental.GraphView; | ||
using UnityEngine.UIElements; | ||
using PortView = UnityEditor.Experimental.GraphView.Port; | ||
|
||
namespace RedOwl.Sleipnir.Editor | ||
{ | ||
public class SleipnirPortView : PortView | ||
{ | ||
public SleipnirPortView(Orientation orientation, PortDirection direction, PortCapacity capacity, Type type, IEdgeConnectorListener listener) : base(orientation, ConvertDirection(direction), ConvertCapacity(capacity), type) | ||
{ | ||
m_EdgeConnector = new EdgeConnector<Edge>(listener); | ||
this.AddManipulator(m_EdgeConnector); | ||
} | ||
|
||
private static Direction ConvertDirection(PortDirection value) => value == PortDirection.Input ? Direction.Input : Direction.Output; | ||
private static Capacity ConvertCapacity(PortCapacity value) => value == PortCapacity.Single ? Capacity.Single : Capacity.Multi; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.