[ Web Proxy ]
URL:
Viewing: https://docs.unity3d.com/ScriptReference/Unity.GraphToolkit.Editor.Node.OnDefinePorts.html [Back]  [Original]

Unity - Scripting API: Unity.GraphToolkit.Editor.Node.OnDefinePorts
Version: Unity 6.5 (6000.5)
    • Supported
    • Legacy
    LanguageEnglish
    • C#

    Node.OnDefinePorts

    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
    Your name Your email Suggestion* Submit suggestion

    Cancel

    Declaration

    protected void OnDefinePorts(IPortDefinitionContext context);

    Parameters

    Parameter Description
    context Provides methods for defining input and output ports.

    Description

    Called during Node.DefineNode to define the input and output ports of the node.

    This method is called after Node.OnDefineOptions and is used to declare the structure of the node's connectivity. Use the provided IPortDefinitionContext to define input and output ports using a builder pattern. The port builder pattern enables fluent configuration of ports by chaining methods such as WithDisplayName, WithDefaultValue, or WithConnectorUI, followed by Build() to finalize the port. The portName parameter passed to AddInputPort or AddOutputPort serves as the port's unique identifier. The portName parameter must be unique within its direction (input or output) on the node and is also used as the display name unless you explicitly call WithDisplayName. You also use the portName identifier to call Node.GetInputPortByName.

     protected override void OnDefinePorts(IPortDefinitionContext context)
     {
         var inputPort = context.AddInputPort<string>("stringInput")
             .WithDisplayName("String Input")
             .WithDefaultValue("Default Value")
             .Build();

    var outputPort = context.AddOutputPort("myOutput") .WithDisplayName("My Output Port") .WithDataType(typeof(float)) .WithConnectorUI(PortConnectorUI.Arrowhead) .Build(); }

    Web Proxy Viewer  |  New URL  |  Original Page