docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IConstantNode

    Interface for a specialized node that outputs a fixed value of a specific data type.

    Inherited Members
    INode.inputPortCount
    INode.GetInputPort(int)
    INode.GetInputPorts()
    INode.GetInputPortByName(string)
    INode.outputPortCount
    INode.GetOutputPort(int)
    INode.GetOutputPorts()
    INode.GetOutputPortByName(string)
    Namespace: Unity.GraphToolkit.Editor
    Assembly: Unity.GraphToolkit.Editor.dll
    Syntax
    public interface IConstantNode : INode
    Remarks

    Use constant nodes to represent a static, predefined value in the graph. This value remains unchanged and is typically used to feed constant input into computations. To retrieve the value, use TryGetValue<T>(out T). This method is type-safe and provides access to the node’s value if the type matches. The dataType property identifies the constant's type.

    Properties

    dataType

    The data type of the constant node's value.

    Declaration
    Type dataType { get; }
    Property Value
    Type Description
    Type
    Remarks

    The type returned by this property indicates the kind of value the constant node holds, such as float, int, string, or a custom type.

    Methods

    TryGetValue<T>(out T)

    Attempts to retrieve the value of the constant node as the specified type.

    Declaration
    bool TryGetValue<T>(out T value)
    Parameters
    Type Name Description
    T value

    The output parameter that holds the value if the conversion is successful.

    Returns
    Type Description
    bool

    true if the value was successfully retrieved and cast to T; otherwise, false.

    Type Parameters
    Name Description
    T

    The type to retrieve the value as.

    Remarks

    This method provides type-safe access to the constant's stored value. It performs a type check and conversion internally. If the value cannot be cast to T, the method returns false and value is set to the default value of T.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)