Editor/ShaderGraphPlus/Nodes/MatrixConstantNode.cs

Abstract generic editor node representing a matrix constant in a Shader Graph extension. Stores a named constant value of type T, exposes title and editor UI hints, and implements interfaces for constant nodes and matrix constants while leaving shader parameter initialization methods unimplemented.

Obfuscated Code

namespace ShaderGraphPlus.Nodes;

public abstract class MatrixConstantNode<T> : ShaderNodePlus, IConstantNode, IConstantMatrixNode
{
	[JsonIgnore, Hide, Browsable( false )]
	public override Color NodeTitleColor => ShaderGraphPlusTheme.NodeHeaderColors.ConstantValueNode;

	public string Name { get; set; } = "";

	[Hide]
	public override string Title => string.IsNullOrWhiteSpace( Name ) ?
		$"{DisplayInfo.For( this ).Name}" :
		$"{DisplayInfo.For( this ).Name} ( {Name} )";

	[InlineEditor]
	public T Value { get; set; }

	/// <summary>
	/// Enable this if you want to be able to set this via an Attribute via code. 
	/// False means it wont be generated as a global in the generated shader and thus will be local to the code.
	/// </summary>
	[Hide]
	public bool IsAttribute { get; set; } = false;

	public object GetValue()
	{
		return Value;
	}

	public BaseNodePlus InitializeMaterialParameterNode()
	{
		throw new NotImplementedException();
	}

	public virtual BlackboardParameter InitializeMaterialParameter( string name )
	{
		throw new NotImplementedException();
	}

	public virtual BlackboardParameter InitializeSubgraphInputParameter( string name )
	{
		throw new NotImplementedException();
	}
}