From 3667e26b057c4887fe0259f041d995afb6aa47ba Mon Sep 17 00:00:00 2001 From: "fernando.toigo" Date: Thu, 24 Oct 2019 18:29:50 -0300 Subject: [PATCH] Added possibility of overriding the body highlight style and the header title style of a node --- Scripts/Editor/NodeEditor.cs | 14 ++++++++++++-- Scripts/Editor/NodeEditorGUI.cs | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index 13440ea..0bd1db0 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -25,7 +25,7 @@ namespace XNodeEditor { #endif public virtual void OnHeaderGUI() { - GUILayout.Label(target.name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); + GUILayout.Label(target.name, GetHeaderTitleStyle(), GUILayout.Height(30)); } /// Draws standard field editors for all public fields @@ -100,6 +100,16 @@ namespace XNodeEditor { return NodeEditorResources.styles.nodeBody; } + public virtual GUIStyle GetBodyHighlightStyle() + { + return NodeEditorResources.styles.nodeHighlight; + } + + public virtual GUIStyle GetHeaderTitleStyle() + { + return NodeEditorResources.styles.nodeHeader; + } + /// Add items for the context menu when right-clicking this node. Override to add custom menu items. public virtual void AddContextMenuItems(GenericMenu menu) { // Actions if only one node is selected @@ -143,4 +153,4 @@ namespace XNodeEditor { } } } -} \ No newline at end of file +} diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index cae1f15..d57ff77 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -379,7 +379,7 @@ namespace XNodeEditor { if (selected) { GUIStyle style = new GUIStyle(nodeEditor.GetBodyStyle()); - GUIStyle highlightStyle = new GUIStyle(NodeEditorResources.styles.nodeHighlight); + GUIStyle highlightStyle = new GUIStyle(nodeEditor.GetBodyHighlightStyle()); highlightStyle.padding = style.padding; style.padding = new RectOffset(); GUI.color = nodeEditor.GetTint(); @@ -490,4 +490,4 @@ namespace XNodeEditor { } } } -} \ No newline at end of file +}