Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question how to set ValueInput<Transform>("transform") default value

Discussion in 'Visual Scripting' started by chumomo, Apr 13, 2023.

  1. chumomo

    chumomo

    Joined:
    Jun 30, 2017
    Posts:
    13
    Hello, the example from official docs is
    myValueA = ValueInput<string>("myValueA", "Hello ");
    myValueB = ValueInput<string>("myValueB", String.Empty);

    How to set the default value for transfrom in order to show "This" as default input value in graph?

    thks!
     
  2. termway

    termway

    Joined:
    Jul 5, 2012
    Posts:
    37
    There are several examples in the base Unit that do this (Graphs/Graph Nodes/HasGraph see in your Visual Scripting package ...\Library\PackageCache\com.unity.visualscripting@1.8.0\Runtime\VisualScripting.Flow\Framework\Graph\HasGraph.cs)

    Code (CSharp):
    1.  
    2. [DoNotSerialize]
    3. [PortLabelHidden]
    4. [NullMeansSelf]
    5. public ValueInput tranform { get; protected set; }
    6.  
    7. protected override void Definition()
    8. {
    9.     tranform = ValueInput<Transform>(nameof(tranform), null).NullMeansSelf();
    10.     //....
    11. }