Bolt Multi-line String Fields?

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

using UnityEngine;
using Ludiq;
using Bolt;

public class DialogueLineUnit : Unit {
    [DoNotSerialize] private ValueInput characterId;
    [TextArea]
    [DoNotSerialize] private ValueInput line;
    [DoNotSerialize] private ValueOutput next;

    protected override void Definition() {
        characterId = ValueInput<int>(nameof(characterId), 0);
        line = ValueInput<string>(nameof(line), "Hi there!");
        next = ValueOutput<DialogueUnit>(nameof(next), null);
    }
}

My line of dialogue looks like this:
6353532--706524--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?

1 Like

Has anyone been able to make a multi-line text area for Bolt?

[InspectorTextArea]

https://docs.unity3d.com/bolt/1.4/api/Ludiq.InspectorTextAreaAttribute.html

As far as I can see InspectorTextArea doesn’t do anything at all, unless I’m using it wrong.

[Inspectable, InspectorTextArea, UnitHeaderInspectable]

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 :

    [UnitTitle("Add Text")]
    public class AddTextUnit : BSUnit
    {
        [DoNotSerialize]
        public ControlInput myInputTrigger;

        [DoNotSerialize]
        public ControlOutput myOutputTrigger;

        [DoNotSerialize, Inspectable, InspectorTextArea, UnitHeaderInspectable]
        public ValueInput myText;

        protected override void Definition()
        {
            myInputTrigger = ControlInput("In", Execute);

            myOutputTrigger = ControlOutput("Out");
            Succession(myInputTrigger, myOutputTrigger);

            myText = ValueInput<string>("Text", "UNSET");
            Requirement(myText, myInputTrigger);
        }

        private ControlOutput Execute(Flow aFlow)
        {
            return myOutputTrigger;
        }
    }

But the UI ends up like this:

8159714--1060748--upload_2022-5-26_21-56-32.png

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.

public enum EStopWatch { _0 = 0, _1 = 1, _2 = 2, _3 = 3, _4 = 4}
...
[UnitHeaderInspectable] public EStopWatch eStopWatch;
[DoNotSerialize, UnitHeaderInspectable("")]  public string getTicks => ticks[(int)eStopWatch] == 0 ? "-------------" : ticks[(int)eStopWatch].ToString();
...

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.

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. :slight_smile:

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.

Have you solved this by any chance?

I cannot find this anywhere. does it exist?

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.