Skip to content

Commit 929218e

Browse files
authored
Merge pull request #121 from FreshlyBrewedCode/node-colors
Add support for node accent colors
2 parents b593c2e + be7ca0e commit 929218e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseNodeView.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,12 @@ void InitializeView()
155155
mainContainer.Add(debugContainer);
156156

157157
title = (string.IsNullOrEmpty(nodeTarget.name)) ? nodeTarget.GetType().Name : nodeTarget.name;
158-
159-
initializing = true;
158+
159+
initializing = true;
160160

161161
SetPosition(nodeTarget.position);
162-
162+
SetNodeColor(nodeTarget.color);
163+
163164
AddInputContainer();
164165
}
165166

@@ -632,6 +633,12 @@ protected virtual void DrawDefaultInspector(bool fromInspector = false)
632633
}
633634
}
634635

636+
protected virtual void SetNodeColor(Color color)
637+
{
638+
titleContainer.style.borderBottomColor = new StyleColor(color);
639+
titleContainer.style.borderBottomWidth = new StyleFloat(color.a > 0 ? 5f : 0f);
640+
}
641+
635642
private void AddEmptyField(FieldInfo field, bool fromInspector)
636643
{
637644
if(field.GetCustomAttribute(typeof(InputAttribute)) == null || fromInspector) return;

Assets/com.alelievr.NodeGraphProcessor/Runtime/Elements/BaseNode.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ public abstract class BaseNode
1919
/// </summary>
2020
/// <returns></returns>
2121
public virtual string name => GetType().Name;
22-
22+
23+
/// <summary>
24+
/// The accent color of the node
25+
/// </summary>
26+
public virtual Color color => Color.clear;
27+
2328
/// <summary>
2429
/// Set a custom uss file for the node. We use a Resources.Load to get the stylesheet so be sure to put the correct resources path
2530
/// https://docs.unity3d.com/ScriptReference/Resources.Load.html

0 commit comments

Comments
 (0)