Build String, append String

Forums 💬 NodeCanvas ⚙️ Support Build String, append String

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17976
    anglo
    Participant

      How do I build an string made up of the additions of other strings, such as:

      String 1: The fast
      String 2: and agile white
      String 3: sabana cat
      and (separator)
      String 4: The slow
      String 5: and fat red
      String 6: horse

      String Result:

      The fast and agile white sabana cat
      The slow and fat red horse

      Also, when I put this strings in an UI Text field, how do I break the lines in order to have to separated phrases in two lines?

      #17983
      mikenspired
      Participant

        Needed a break from my work. Something like this work for you? I think adding that text it creates with the n should work for UI text if ur setting the text with a string.
        —————————————–

        using NodeCanvas.Framework;
        using ParadoxNotion.Design;
        using UnityEngine;

        namespace NodeCanvas.Tasks.Actions{

        [Category(“String”)]
        public class ConcatenateString : ActionTask<Transform> {

        public BBParameter<bool> addEndLine = false;

        [RequiredField]
        public BBParameter<string> string1;
        public BBParameter<string> string2;

        [BlackboardOnly]
        public BBParameter<string> newString;

        protected override void OnExecute(){

        if (!addEndLine.value) {
        newString.value = string1.value + string2.value;
        } else {
        newString.value = string1.value + string2.value + “n”;
        }

        EndAction ();
        }
        }
        }

        #17982
        anglo
        Participant

          Is there a chance to have this as a Task Node. I am not a programmer and when I compile it, it just give me errors on my project.
          Kind regards

          #17981
          Gavalakis
          Keymaster

            Hello,

            Thanks @mikenspired. Here is his code formatted and possible to compile:

            Let me know if that works for you.
            Cheers!

            #17980
            anglo
            Participant

              Thank you very much for this. Sorry to bother but I am getting both strings in the same line without separator. What I would like is to have the choice to make two lines. Attached pictures
              Kind regards

              #17979
              anglo
              Participant

                and this

                #17978
                Gavalakis
                Keymaster

                  Hey,

                  Here is a modified version, that combines the two strings as separate lines if “Seperate Lines” is true.

                  #17977
                  anglo
                  Participant

                    That works perfect, thank you very much. How do I do for more than just two lines?

                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • You must be logged in to reply to this topic.