From 629474d0424ca9b0aa5abeea6b13938ed0782285 Mon Sep 17 00:00:00 2001 From: juliocp Date: Mon, 5 Oct 2020 16:25:08 -0300 Subject: [PATCH] Added Noodle Thickness at preferences The default value for the thickness of the noodle can be modified from xNode preferences. This value is only effective if the user does not make an override from the EditorGraph at GetNoodleThickness(...). Many users do not like to edit from the script, this will help in the creation of my new layout template, similar to the new graphView from unity --- Scripts/Editor/NodeEditorPreferences.cs | 3 +++ Scripts/Editor/NodeGraphEditor.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorPreferences.cs b/Scripts/Editor/NodeEditorPreferences.cs index e5fa238..bffec1c 100644 --- a/Scripts/Editor/NodeEditorPreferences.cs +++ b/Scripts/Editor/NodeEditorPreferences.cs @@ -42,6 +42,8 @@ namespace XNodeEditor { [SerializeField] private string typeColorsData = ""; [NonSerialized] public Dictionary typeColors = new Dictionary(); [FormerlySerializedAs("noodleType")] public NoodlePath noodlePath = NoodlePath.Curvy; + public float noodleThickness = 2f; + public NoodleStroke noodleStroke = NoodleStroke.Full; private Texture2D _gridTexture; @@ -160,6 +162,7 @@ namespace XNodeEditor { EditorGUILayout.LabelField("Node", EditorStyles.boldLabel); settings.highlightColor = EditorGUILayout.ColorField("Selection", settings.highlightColor); settings.noodlePath = (NoodlePath) EditorGUILayout.EnumPopup("Noodle path", (Enum) settings.noodlePath); + settings.noodleThickness = EditorGUILayout.FloatField(new GUIContent("Noodle thickness", "Noodle Thickness of the node connections"), settings.noodleThickness); settings.noodleStroke = (NoodleStroke) EditorGUILayout.EnumPopup("Noodle stroke", (Enum) settings.noodleStroke); settings.portTooltips = EditorGUILayout.Toggle("Port Tooltips", settings.portTooltips); settings.dragToCreate = EditorGUILayout.Toggle(new GUIContent("Drag to Create", "Drag a port connection anywhere on the grid to create and connect a node"), settings.dragToCreate); diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index 01de70e..a8bde28 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -125,7 +125,7 @@ namespace XNodeEditor { /// The output this noodle comes from. Never null. /// The output this noodle comes from. Can be null if we are dragging the noodle. public virtual float GetNoodleThickness(XNode.NodePort output, XNode.NodePort input) { - return 5f; + return NodeEditorPreferences.GetSettings().noodleThickness; } public virtual NoodlePath GetNoodlePath(XNode.NodePort output, XNode.NodePort input) {