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
- Type: Method
- Namespace: Unity.GraphToolkit.Editor
- Assembly: UnityEditor
public virtual bool IsConnectionAllowed(IPort output, IPort input)
Parameters
Returns
Type | Description |
|---|---|
| bool | |
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);}