VisualShaderNodeCustom
A C# resource for a custom Visual Shader graph block.
Declare ports and generate shader statements through _GetInputPort*(), _GetOutputPort*() and _GetCode() overrides. Use [Tool, GlobalClass] for automatic editor discovery. A single block needs neither EditorPlugin nor plugin.cfg. A graph node is not a game Entity.
_GetCode() strings contain shader language, not C#. Use the supplied inputVars/outputVars and unique shared-function names. Do not Dispose() a live C# block after handing it to a graph: this detaches its scripted behavior.
Complete example, persistence and verification limits.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
VisualShaderNodeCustomConstructor
public VisualShaderNodeCustom();Properties2
InitializedProperty
public bool Initialized { get; set; }Internal editor-element initialization flag. Do not use it as evidence of GPU compilation or material readiness. When true, ordinary custom-node input-default mutation methods are restricted.
PropertiesProperty
public string Properties { get; set; }Internal serialized dropdown-selection data. Declare choices through _GetProperty*() and read selections through GetOptionIndex(); do not construct this string manually.
Methods22
GetOptionIndexint
public int GetOptionIndex(int option);Read a stored dropdown selection for code generation. If no value is stored for that setting, the native implementation returns 0.
| Name | Type | Default |
|---|---|---|
option | int | — |
optionThe dropdown setting index, not an input port number.
intThe selected choice index.
_GetCategorystring
public virtual string _GetCategory();Set the custom block category path, for example Reckfell/Color. The editor adds an Addons prefix; / separates subcategories. Do not apply block-name restrictions to the entire path.
stringA category path; the Addons prefix need not be supplied.
_GetCodestring
public virtual string _GetCode(Reckfell.Collections.Array<string> inputVars, Reckfell.Collections.Array<string> outputVars, Shader.Mode mode, VisualShader.Type type);Return Reckfell shader-language statements for one block instance. Use inputVars expressions and assign results to outputVars; port labels are not substitutes for these strings. Do not redeclare a shared function in every instance.
| Name | Type | Default |
|---|---|---|
inputVars | Reckfell.Collections.Array<string> | — |
outputVars | Reckfell.Collections.Array<string> | — |
mode | Shader.Mode | — |
type | VisualShader.Type | — |
inputVarsInput expressions or variable names ordered by port index.
outputVarsOutput variable names to assign results to.
modeThe shader mode, such as CanvasItem or Spatial.
typeThe graph stage, such as Fragment.
stringThe calculation statements, such as result = mix(a, b, weight); using actual argument names.
_GetDefaultInputPortint
public virtual int _GetDefaultInputPort(VisualShaderNode.PortType type);Choose an input when creating a block by dragging a connection into empty graph space. Return a suitable index for the supplied type. The 1.0.0 native fallback returns 0 when not overridden.
| Name | Type | Default |
|---|---|---|
type | VisualShaderNode.PortType | — |
typeThe dragged connection type.
intAn input port index.
_GetDescriptionstring
public virtual string _GetDescription();Set the block description in the add dialog. Briefly state the operation, ranges and mode limitations.
stringThe description text.
_GetFuncCodestring
public virtual string _GetFuncCode(Shader.Mode mode, VisualShader.Type type);Add shared code at the beginning of shader functions for this block type. Insertion order across different custom types is unspecified; do not depend on that order.
| Name | Type | Default |
|---|---|---|
mode | Shader.Mode | — |
type | VisualShader.Type | — |
modeThe shader mode.
typeThe stage whose function receives code.
stringFunction-prefix statements, or an empty string.
_GetGlobalCodestring
public virtual string _GetGlobalCode(Shader.Mode mode);Add shared declarations outside shader functions. The generator emits them once per used C# script, even with several instances. Use unique names and do not store instance-specific state here.
| Name | Type | Default |
|---|---|---|
mode | Shader.Mode | — |
modeThe generated shader mode.
stringGlobal shader-language declarations, or an empty string.
_GetInputPortCountint
public virtual int _GetInputPortCount();Declare the number of input ports. Name, type and default callbacks receive indices from 0 through this count minus one.
intThe input count; without an override there are no inputs.
_GetInputPortDefaultValueVariant
public virtual Variant _GetInputPortDefaultValue(int port);Return an initial value for an unconnected input. The editor applies this callback when inserting through its UI. In 1.0.0, programmatic VisualShader.AddNode() does not write these defaults: explicitly call SetInputPortDefaultValue() after adding.
| Name | Type | Default |
|---|---|---|
port | int | — |
portThe zero-based port index.
VariantA Variant matching the port type; Nil means no declared value.
_GetInputPortNamestring
public virtual string _GetInputPortName(int port);Set an input port label. This is not a ready-to-use GPU variable name: use the supplied inputVars[port] expression in _GetCode().
| Name | Type | Default |
|---|---|---|
port | int | — |
portThe zero-based port index.
stringThe input label.
_GetInputPortTypeVisualShaderNode.PortType
public virtual VisualShaderNode.PortType _GetInputPortType(int port);Declare an input data type. Keep its default and shader expressions consistent; Vector3D corresponds to vec3 and Scalar to float.
| Name | Type | Default |
|---|---|---|
port | int | — |
portThe zero-based port index.
VisualShaderNode.PortTypeThe requested input type.
_GetNamestring
public virtual string _GetName();Set the block name in the add dialog and graph. Editor registration requires a valid ASCII identifier without spaces, such as BlendTint.
stringThe block name.
_GetOutputPortCountint
public virtual int _GetOutputPortCount();Declare the number of output ports. Assign each calculated output in _GetCode().
intThe output count; without an override there are no outputs.
_GetOutputPortNamestring
public virtual string _GetOutputPortName(int port);Set an output port label. Assign to outputVars[port] in _GetCode(), not to the label string.
| Name | Type | Default |
|---|---|---|
port | int | — |
portThe zero-based port index.
stringThe output label.
_GetOutputPortTypeVisualShaderNode.PortType
public virtual VisualShaderNode.PortType _GetOutputPortType(int port);Declare an output data type; its generated assignment must produce a compatible value.
| Name | Type | Default |
|---|---|---|
port | int | — |
portThe zero-based port index.
VisualShaderNode.PortTypeThe requested output type.
_GetPropertyCountint
public virtual int _GetPropertyCount();Declare the number of dropdown settings on the custom block; this is not the input port count. Supply each setting name, option list and, when needed, default index.
intThe number of dropdown settings.
_GetPropertyDefaultIndexint
public virtual int _GetPropertyDefaultIndex(int index);Declare the initial selected index of a dropdown setting. It must match the array returned by _GetPropertyOptions().
| Name | Type | Default |
|---|---|---|
index | int | — |
indexThe zero-based dropdown setting index.
intThe zero-based selected choice index.
_GetPropertyNamestring
public virtual string _GetPropertyName(int index);Set a block dropdown setting label.
| Name | Type | Default |
|---|---|---|
index | int | — |
indexThe zero-based dropdown setting index.
stringThe setting label.
_GetPropertyOptionsstring[]
public virtual string[] _GetPropertyOptions(int index);Declare the ordered choices of a dropdown setting. Read its selected index through GetOptionIndex().
| Name | Type | Default |
|---|---|---|
index | int | — |
indexThe zero-based dropdown setting index.
string[]An array of choice labels.
_GetReturnIconTypeVisualShaderNode.PortType
public virtual VisualShaderNode.PortType _GetReturnIconType();Choose the result-type icon in the add dialog. This is UI metadata; _GetOutputPortType() defines actual output types.
VisualShaderNode.PortTypeThe port type used for the icon.
_IsAvailablebool
public virtual bool _IsAvailable(Shader.Mode mode, VisualShader.Type type);Filter block availability by shader mode and graph stage; true by default. This does not translate shader code between modes or prove GPU compatibility.
| Name | Type | Default |
|---|---|---|
mode | Shader.Mode | — |
type | VisualShader.Type | — |
modeThe shader mode being checked.
typeThe graph stage being checked.
booltrue for a supported context; false to exclude it.
_IsHighendbool
public virtual bool _IsHighend();Mark the block as requiring Forward+ or Mobile features in the add dialog. The default is false. This is editor guidance, not a renderer switch or a substitute for checking GPU code.
booltrue for the high-end marker; otherwise false.