Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


IsConnectionAllowed(IPort, IPort)

Determines whether a connection between the specified output and input ports is allowed.
Read time 1 minuteLast updated 6 days ago

Definition

public virtual bool IsConnectionAllowed(IPort output, IPort input)

Parameters

output

The output port from which the connection originates.

input

The input port to which the connection is being made.

Returns

Type

Description

bool
true
if a connection between the specified ports is allowed; otherwise,
false
.

Remarks

The default implementation checks type compatibility by verifying that the input port's IPort.DataType is assignable from the output port's IPort.DataType. This allows connections between ports of the same type or where the output type is derived from the input type.
Override this method in derived graph classes to implement custom connection validation logic, such as additional type constraints, node-specific rules, or graph-level restrictions.

Examples

public override bool IsConnectionAllowed(IPort output, IPort input){ // Allow connection if the output is a string and the input is an int if (output.DataType == typeof(string) && input.DataType == typeof(int)) return true; // Fallback on the default behaviour return base.IsConnectionAllowed(output, input);}