mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
ShaderLab style noodles
This commit is contained in:
commit
77d7802b7e
@ -267,6 +267,41 @@ namespace XNodeEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NoodlePath.ShaderLab:
|
||||||
|
Vector2 start = gridPoints[0];
|
||||||
|
Vector2 end = gridPoints[length - 1];
|
||||||
|
//Modify first and last point in array so we can loop trough them nicely.
|
||||||
|
gridPoints[0] = gridPoints[0] + Vector2.right * (20 / zoom);
|
||||||
|
gridPoints[length - 1] = gridPoints[length - 1] + Vector2.left * (20 / zoom);
|
||||||
|
//Draw first vertical lines going out from nodes
|
||||||
|
Handles.color = gradient.Evaluate(0f);
|
||||||
|
DrawAAPolyLineNonAlloc(thickness, start, gridPoints[0]);
|
||||||
|
Handles.color = gradient.Evaluate(1f);
|
||||||
|
DrawAAPolyLineNonAlloc(thickness, end, gridPoints[length - 1]);
|
||||||
|
for (int i = 0; i < length - 1; i++) {
|
||||||
|
Vector2 point_a = gridPoints[i];
|
||||||
|
Vector2 point_b = gridPoints[i + 1];
|
||||||
|
// Draws the line with the coloring.
|
||||||
|
Vector2 prev_point = point_a;
|
||||||
|
// Approximately one segment per 5 pixels
|
||||||
|
int segments = (int) Vector2.Distance(point_a, point_b) / 5;
|
||||||
|
|
||||||
|
int draw = 0;
|
||||||
|
for (int j = 0; j <= segments; j++) {
|
||||||
|
draw++;
|
||||||
|
float t = j / (float) segments;
|
||||||
|
Vector2 lerp = Vector2.Lerp(point_a, point_b, t);
|
||||||
|
if (draw > 0) {
|
||||||
|
if (i == length - 2) Handles.color = gradient.Evaluate(t);
|
||||||
|
DrawAAPolyLineNonAlloc(thickness, prev_point, lerp);
|
||||||
|
}
|
||||||
|
prev_point = lerp;
|
||||||
|
if (stroke == NoodleStroke.Dashed && draw >= 2) draw = -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gridPoints[0] = start;
|
||||||
|
gridPoints[length - 1] = end;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ using UnityEngine;
|
|||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace XNodeEditor {
|
namespace XNodeEditor {
|
||||||
public enum NoodlePath { Curvy, Straight, Angled }
|
public enum NoodlePath { Curvy, Straight, Angled, ShaderLab }
|
||||||
public enum NoodleStroke { Full, Dashed }
|
public enum NoodleStroke { Full, Dashed }
|
||||||
|
|
||||||
public static class NodeEditorPreferences {
|
public static class NodeEditorPreferences {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user