Editor/UpgradedShaderGraph/Nodes/BaseNodes/Reroute.cs

Defines a reroute node for a shader graph editor. RerouteNode is an abstract editor node with a Comment and an Input port and creates a RerouteUI. Reroute is a concrete node that exposes a hidden Output Result which returns the compiler result of the Input and marks it constant.

Reflection

namespace Editor.ShaderGraphExtras.Nodes;
public abstract class RerouteNode : BaseNode, IRerouteNode
{
	/// <summary>
	/// Comment to show above this node
	/// </summary>
	public string Comment { get; set; }

	[Input, Hide, Title( "" )]
	public NodeInput Input { get; set; }

	public override NodeUI CreateUI( GraphView view )
	{
		return new RerouteUI( view, this );
	}
}

public sealed class Reroute : RerouteNode
{
	[Output, Hide, Title( "" )]
	public NodeResult.Func Result => ( GraphCompiler compiler ) =>
	{
		var result = compiler.ResultOrDefault( Input, 0.0f );
		result.Constant = true;
		return result;
	};
}