mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Added nodeGraphEditor.GetNoodleColor
Now you can override the color of noodles!
This commit is contained in:
parent
f86b2b6d42
commit
979bd5f7cf
@ -202,11 +202,11 @@ namespace XNodeEditor {
|
||||
Rect fromRect;
|
||||
if (!_portConnectionPoints.TryGetValue(output, out fromRect)) continue;
|
||||
|
||||
Color connectionColor = graphEditor.GetPortColor(output);
|
||||
|
||||
for (int k = 0; k < output.ConnectionCount; k++) {
|
||||
XNode.NodePort input = output.GetConnection(k);
|
||||
|
||||
Color noodleColor = graphEditor.GetNoodleColor(output, input);
|
||||
|
||||
// Error handling
|
||||
if (input == null) continue; //If a script has been updated and the port doesn't exist, it is removed and null is returned. If this happens, return.
|
||||
if (!input.IsConnectedTo(output)) input.Connect(output);
|
||||
@ -219,7 +219,7 @@ namespace XNodeEditor {
|
||||
gridPoints.Add(fromRect.center);
|
||||
gridPoints.AddRange(reroutePoints);
|
||||
gridPoints.Add(toRect.center);
|
||||
DrawNoodle(connectionColor, gridPoints);
|
||||
DrawNoodle(noodleColor, gridPoints);
|
||||
|
||||
// Loop through reroute points again and draw the points
|
||||
for (int i = 0; i < reroutePoints.Count; i++) {
|
||||
@ -235,7 +235,7 @@ namespace XNodeEditor {
|
||||
GUI.DrawTexture(rect, NodeEditorResources.dotOuter);
|
||||
}
|
||||
|
||||
GUI.color = connectionColor;
|
||||
GUI.color = noodleColor;
|
||||
GUI.DrawTexture(rect, NodeEditorResources.dot);
|
||||
if (rect.Overlaps(selectionBox)) selection.Add(rerouteRef);
|
||||
if (rect.Contains(mousePos)) hoveredReroute = rerouteRef;
|
||||
|
||||
@ -63,14 +63,22 @@ namespace XNodeEditor {
|
||||
menu.AddCustomContextMenuItems(target);
|
||||
}
|
||||
|
||||
/// <summary> Returned color is used to color noodles </summary>
|
||||
public virtual Color GetNoodleColor(XNode.NodePort output, XNode.NodePort input) {
|
||||
return GetTypeColor(output.ValueType);
|
||||
}
|
||||
|
||||
/// <summary> Returned color is used to color ports </summary>
|
||||
public virtual Color GetPortColor(XNode.NodePort port) {
|
||||
return GetTypeColor(port.ValueType);
|
||||
}
|
||||
|
||||
/// <summary> Returns generated color for a type. This color is editable in preferences </summary>
|
||||
public virtual Color GetTypeColor(Type type) {
|
||||
return NodeEditorPreferences.GetTypeColor(type);
|
||||
}
|
||||
|
||||
/// <summary> Override to display custom tooltips </summary>
|
||||
public virtual string GetPortTooltip(XNode.NodePort port) {
|
||||
Type portType = port.ValueType;
|
||||
string tooltip = "";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user