Skip to main content

Class OperatorNode<T1, T2, TOut>

Abstract base node for performing mathematical/logic operations on two input values.

public abstract class OperatorNode<T1, T2, TOut> : BaseNode

Type Parameters​

NameTypeDescription
T1The type of the first input value.
T2The type of the second input value.
TOutThe type of the output value.

Inheritance​

Examples​

Subclass OperatorNode and override XNode.Node.GetValue to implement a concrete arithmetic or logic operation. The type parameters drive the automatically-generated port types; Value_A and Value_B already handle type conversion and port-connection fallback, so the override body stays minimal. The pattern below mirrors the existing AddNode implementation.

using XNode;
using mobisim.Scenes.SNGraph;

[CreateNodeMenu("Operator/Max")]
public class MaxNode : OperatorNode
{
// Return the larger of the two connected (or inline) values.
public override object GetValue(NodePort port)
=> Mathf.Max(Value_A, Value_B);

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

Fields​

A​

Input port for the first operand.

public T1 A

Field Value​

T1

B​

Input port for the second operand.

public T2 B

Field Value​

T2

Out​

Output port that provides the result of the operation.

public TOut Out

Field Value​

TOut

Properties​

Value_A​

The first input value for the mathematical operation.

protected virtual T1 Value_A { get; }

Property Value​

T1

Value_B​

The second input value for the mathematical operation.

protected virtual T2 Value_B { get; }

Property Value​

T2