Skip to content

Commit

Permalink
Merge pull request #121 from FreshlyBrewedCode/node-colors
Browse files Browse the repository at this point in the history
Add support for node accent colors
  • Loading branch information
alelievr committed Jan 22, 2021
2 parents 36161da + 2cc7345 commit 890b519
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 10 additions & 3 deletions Editor/Views/BaseNodeView.cs
Expand Up @@ -155,11 +155,12 @@ void InitializeView()
mainContainer.Add(debugContainer);

title = (string.IsNullOrEmpty(nodeTarget.name)) ? nodeTarget.GetType().Name : nodeTarget.name;

initializing = true;
initializing = true;

SetPosition(nodeTarget.position);

SetNodeColor(nodeTarget.color);

AddInputContainer();
}

Expand Down Expand Up @@ -632,6 +633,12 @@ protected virtual void DrawDefaultInspector(bool fromInspector = false)
}
}

protected virtual void SetNodeColor(Color color)
{
titleContainer.style.borderBottomColor = new StyleColor(color);
titleContainer.style.borderBottomWidth = new StyleFloat(color.a > 0 ? 5f : 0f);
}

private void AddEmptyField(FieldInfo field, bool fromInspector)
{
if(field.GetCustomAttribute(typeof(InputAttribute)) == null || fromInspector) return;
Expand Down
7 changes: 6 additions & 1 deletion Runtime/Elements/BaseNode.cs
Expand Up @@ -19,7 +19,12 @@ public abstract class BaseNode
/// </summary>
/// <returns></returns>
public virtual string name => GetType().Name;


/// <summary>
/// The accent color of the node
/// </summary>
public virtual Color color => Color.clear;

/// <summary>
/// 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
/// https://docs.unity3d.com/ScriptReference/Resources.Load.html
Expand Down

0 comments on commit 890b519

Please sign in to comment.