Search Unity

Bolt Multi-line String Fields?

Discussion in 'Visual Scripting' started by ModLunar, Sep 27, 2020.

  1. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    I made a custom Unit (node) with the following code, and clicking Tools > Bolt > Build Unit Options in the menu in Unity:

    Code (CSharp):
    1. using UnityEngine;
    2. using Ludiq;
    3. using Bolt;
    4.  
    5. public class DialogueLineUnit : Unit {
    6.     [DoNotSerialize] private ValueInput characterId;
    7.     [TextArea]
    8.     [DoNotSerialize] private ValueInput line;
    9.     [DoNotSerialize] private ValueOutput next;
    10.  
    11.     protected override void Definition() {
    12.         characterId = ValueInput<int>(nameof(characterId), 0);
    13.         line = ValueInput<string>(nameof(line), "Hi there!");
    14.         next = ValueOutput<DialogueUnit>(nameof(next), null);
    15.     }
    16. }
    17.  
    My line of dialogue looks like this:
    upload_2020-9-26_22-4-17.png

    This is hard to make dialogue, because the text is in 1 line.
    Not only that, I sometimes want line breaks in my dialogue lines.


    Using the usual [TextArea] attribute has no effect.

    How do I make this a multi-line text area?
     
    Last edited: Sep 27, 2020
    Createman likes this.
  2. Createman

    Createman

    Joined:
    Apr 14, 2013
    Posts:
    16
    Has anyone been able to make a multi-line text area for Bolt?
     
  3. zzmingo

    zzmingo

    Joined:
    Sep 8, 2016
    Posts:
    10
  4. Redux

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    146
    As far as I can see InspectorTextArea doesn't do anything at all, unless I'm using it wrong.
     
  5. uniras

    uniras

    Joined:
    May 20, 2022
    Posts:
    1
    [Inspectable, InspectorTextArea, UnitHeaderInspectable]
     
  6. Guy-Corbett

    Guy-Corbett

    Joined:
    Jun 30, 2013
    Posts:
    3
    Could you offer a little more explanation about how to use these attributes? I am having no luck. I have a simple unit, the code for which that looks like this :

    Code (CSharp):
    1.     [UnitTitle("Add Text")]
    2.     public class AddTextUnit : BSUnit
    3.     {
    4.         [DoNotSerialize]
    5.         public ControlInput myInputTrigger;
    6.  
    7.         [DoNotSerialize]
    8.         public ControlOutput myOutputTrigger;
    9.  
    10.         [DoNotSerialize, Inspectable, InspectorTextArea, UnitHeaderInspectable]
    11.         public ValueInput myText;
    12.  
    13.         protected override void Definition()
    14.         {
    15.             myInputTrigger = ControlInput("In", Execute);
    16.  
    17.             myOutputTrigger = ControlOutput("Out");
    18.             Succession(myInputTrigger, myOutputTrigger);
    19.  
    20.             myText = ValueInput<string>("Text", "UNSET");
    21.             Requirement(myText, myInputTrigger);
    22.         }
    23.  
    24.         private ControlOutput Execute(Flow aFlow)
    25.         {
    26.             return myOutputTrigger;
    27.         }
    28.     }
    But the UI ends up like this:

    upload_2022-5-26_21-56-32.png
     
  7. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    398
    InspectorTextArea, refers to when you view the sidebar/inspector, you will see a text area for the value. UnitHeaderInspectable refers to having a custom inspector for your type in the header. In this case ValueInput has no inspector and wouldn't anyway. If you had a [UnitHeaderInspectable] string it would then add a string in the UnitHeader.

    Code (CSharp):
    1. public enum EStopWatch { _0 = 0, _1 = 1, _2 = 2, _3 = 3, _4 = 4}
    2. ...
    3. [UnitHeaderInspectable] public EStopWatch eStopWatch;
    4. [DoNotSerialize, UnitHeaderInspectable("")]  public string getTicks => ticks[(int)eStopWatch] == 0 ? "-------------" : ticks[(int)eStopWatch].ToString();
    5. ...
    This shows a dropdown enum 0..4, and a text line which is triggered in loop.

    I think to achieve your goal, would need writing your own node altogether, or adding an additional text box viewer. The standard setup only allows a single line, as multiline would mean ports automatically move accordingly which isn't standard.
     
  8. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    398
    The best option outside that is a multiline string literal input, think this exists somewhere (addons?). But I understand it's nice to have everything in one node - be prepared for some heavy work on that approach though! Fun though. :)

    If in doubt, look at all the code that exists in the package/addons and figure out how to draw/override things. If you add the packages to your solution (Unity option), you can view all the unity code along side yours, which has been the best helpfile for me.
     
  9. ttrescak

    ttrescak

    Joined:
    Apr 18, 2018
    Posts:
    3
    Have you solved this by any chance?
     
  10. ttrescak

    ttrescak

    Joined:
    Apr 18, 2018
    Posts:
    3
    I cannot find this anywhere. does it exist?
     
  11. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    398
    Yep its called Multi Line String. But doesn't look like it's in the master branch of the Addons, maybe it breaks in newer versions.