Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

Graph.IsConnectionAllowed

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool IsConnectionAllowed(IPort output, IPort input);

Parameters

Parameter Description
output The output port from which the connection originates.
input The input port to which the connection is being made.

Returns

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

Description

Determines whether a connection between the specified output and input ports is allowed.

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.

 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); }