Skip to main content

Class BaseNode

Base class for all nodes in the Scene Node Graph, which controls scene flow and branching logic in the game. Ensures nodes are distinct from other graph types and can be recognized by the Scene Node Graph's custom editor.

public abstract class BaseNode : Node

Inheritance​

Derived​

Examples​

Create a custom data node that multiplies a float input by a constant factor and exposes the result on an output port. Add [Input]/[Output] fields on public members so xNode generates the ports automatically; override XNode.Node.GetValue to supply the computed value when downstream nodes pull the port.

using XNode;
using mobisim.Scenes.SNGraph;

[CreateNodeMenu("Custom/Scale")]
public class ScaleNode : BaseNode
{
[Input(backingValue = ShowBackingValue.Unconnected,
typeConstraint = TypeConstraint.Strict,
connectionType = ConnectionType.Override)]
public float Value;

public float Factor = 2f;

[Output(backingValue = ShowBackingValue.Never,
connectionType = ConnectionType.Multiple)]
public float Out;

public override object GetValue(NodePort port)
{
if (port.fieldName == nameof(Out))
return GetInputValue(nameof(Value), Value) * Factor;
return null;
}

private void Reset() => name = "Scale";
}