From ba48e32a22b5b83d136345db248a91c72ee88f1c Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Sun, 4 Aug 2019 22:25:51 +0200 Subject: [PATCH] Moved RerouteReference to own script --- Scripts/Editor/Internal.meta | 8 ++++++++ Scripts/Editor/Internal/RerouteReference.cs | 20 +++++++++++++++++++ .../Editor/Internal/RerouteReference.cs.meta | 11 ++++++++++ Scripts/Editor/NodeEditorAction.cs | 18 +---------------- Scripts/Editor/NodeEditorGUI.cs | 1 + 5 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 Scripts/Editor/Internal.meta create mode 100644 Scripts/Editor/Internal/RerouteReference.cs create mode 100644 Scripts/Editor/Internal/RerouteReference.cs.meta diff --git a/Scripts/Editor/Internal.meta b/Scripts/Editor/Internal.meta new file mode 100644 index 0000000..600ad29 --- /dev/null +++ b/Scripts/Editor/Internal.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6a1bbc054e282346a02e7bbddde3206 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/Internal/RerouteReference.cs b/Scripts/Editor/Internal/RerouteReference.cs new file mode 100644 index 0000000..4e21130 --- /dev/null +++ b/Scripts/Editor/Internal/RerouteReference.cs @@ -0,0 +1,20 @@ +using UnityEngine; + +namespace XNodeEditor.Internal { + public struct RerouteReference { + public XNode.NodePort port; + public int connectionIndex; + public int pointIndex; + + public RerouteReference(XNode.NodePort port, int connectionIndex, int pointIndex) { + this.port = port; + this.connectionIndex = connectionIndex; + this.pointIndex = pointIndex; + } + + public void InsertPoint(Vector2 pos) { port.GetReroutePoints(connectionIndex).Insert(pointIndex, pos); } + public void SetPoint(Vector2 pos) { port.GetReroutePoints(connectionIndex) [pointIndex] = pos; } + public void RemovePoint() { port.GetReroutePoints(connectionIndex).RemoveAt(pointIndex); } + public Vector2 GetPoint() { return port.GetReroutePoints(connectionIndex) [pointIndex]; } + } +} \ No newline at end of file diff --git a/Scripts/Editor/Internal/RerouteReference.cs.meta b/Scripts/Editor/Internal/RerouteReference.cs.meta new file mode 100644 index 0000000..9a2f9cb --- /dev/null +++ b/Scripts/Editor/Internal/RerouteReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 399f3c5fb717b2c458c3e9746f8959a3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 4b57ba1..f0ebec0 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; +using XNodeEditor.Internal; namespace XNodeEditor { public partial class NodeEditorWindow { @@ -31,23 +32,6 @@ namespace XNodeEditor { private bool isDoubleClick = false; private Vector2 lastMousePosition; - private struct RerouteReference { - public XNode.NodePort port; - public int connectionIndex; - public int pointIndex; - - public RerouteReference(XNode.NodePort port, int connectionIndex, int pointIndex) { - this.port = port; - this.connectionIndex = connectionIndex; - this.pointIndex = pointIndex; - } - - public void InsertPoint(Vector2 pos) { port.GetReroutePoints(connectionIndex).Insert(pointIndex, pos); } - public void SetPoint(Vector2 pos) { port.GetReroutePoints(connectionIndex) [pointIndex] = pos; } - public void RemovePoint() { port.GetReroutePoints(connectionIndex).RemoveAt(pointIndex); } - public Vector2 GetPoint() { return port.GetReroutePoints(connectionIndex) [pointIndex]; } - } - public void Controls() { wantsMouseMove = true; Event e = Event.current; diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 6304754..55ffd31 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; +using XNodeEditor.Internal; namespace XNodeEditor { /// Contains GUI methods