playMaker

Author Topic: new line into UGui Text Set Text (again?) [SOLVED]  (Read 2349 times)

Litow

  • Playmaker Newbie
  • *
  • Posts: 26
new line into UGui Text Set Text (again?) [SOLVED]
« on: November 24, 2017, 05:14:48 PM »
I apologize up front.
I played with Playmaker for a couple of months and got 90% of my app done flawlessly. Xmls, multiple canvases interaction, animated sprites and all. But I feel like a complete newbie asking this.

I browsed the forum up and down and tried as many suggestions I could find. But for whatever reason I still cannot get to replace a comma in a string variable with a new line, and use that to set a Text component.
I can see the comma getting replaced, but the text always ends up being shown as one line.

I could use the StringAddNewLine action. But my string is actually made out of about 30 lines, comma divided. Before having to enter each one into an Element of that action I would like to find out the more elegant solution.

I tried StringSplit the comma into a StringJoin using any combination of new line shortcut separators I know of and/or found around.
  \\n //n \\r\\n //r//n \r\n /r/n <br>
As well as manually copying a new line from a text editor and pasting it into the separators or a variable.
To no avail.

I also tried a simple BuildString with all the same options. Same failure.

I tried a StringReplace. Same.

Reading the forum, i understand this "may" be a limitation of how Unity2017 ingests strings.

But given that I can add my own new line text directly into the component.
I thought to ask here Im not missing something obvious. So...

Given a very long variable string like this:
a,b,c,...,...

How could one programmatically break that to set UGuiTextSetText's Text so that the component resolves:
a
b
c
...
...

Please.... :)
Im using Playmaker 1.8.5 on a mac and Unity2017
« Last Edit: November 24, 2017, 06:00:01 PM by Litow »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: new line into UGui Text Set Text (again?)
« Reply #1 on: November 24, 2017, 05:32:38 PM »
Hi.
You were actually pretty close.

state 1 : use 'string split'. and store in (stringArray)

state 2 : use 'array get next' and  in array set (stringArray)
place a loop event (Next) and a finished event (Done)
in result make a variable (line) Connect 'Next' to state 3 and Done to whatever you do next.

state 3 : use 'String Add New Line' and set '2' string parts.
in element 0 make a new variable (LinedText)
in element 1 place 'line' variable.
in store result place 'LinedText'

that should do the trick.

Litow

  • Playmaker Newbie
  • *
  • Posts: 26
Re: new line into UGui Text Set Text (again?)
« Reply #2 on: November 24, 2017, 05:51:51 PM »
Ah!
Brilliant... But thank you, Sir!!!!!

I also just now ended up cheating a bit and tried building a new Replace function forcing the new line in there... which also did the trick... i guess desperation is the mother of invention ;)
Attached here (but i can take it down if against policies...!)


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: new line into UGui Text Set Text (again?) [SOLVED]
« Reply #3 on: November 25, 2017, 05:30:22 PM »
Hi,
On the contrary, most of the custom actions found on the Ecosystem are made and shared by the community :D

But i do think the 'Every Frame' is not needed on this, if you would need to use it multiple times it is still better to use a send event (performance wise)

Is it ok for me to update the action so i can place it on the Ecosystem?

Litow

  • Playmaker Newbie
  • *
  • Posts: 26
Re: new line into UGui Text Set Text (again?) [SOLVED]
« Reply #4 on: August 26, 2018, 05:38:08 AM »
Sorry for the delay!!!
I seem to have missed this reply as well.
Please, do as you see fit!

hamid389

  • Playmaker Newbie
  • *
  • Posts: 1
Re: new line into UGui Text Set Text (again?) [SOLVED]
« Reply #5 on: September 17, 2019, 04:32:03 AM »
hi
finally i found a good way to use newline in playmaker arrays !

1-use this script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Dialogues : MonoBehaviour
{
   [Header("TextArea")]
   [Space(10)]
   [TextArea]
   public string [] TextArea = new string[1];
}


2-attach it to a game obj and write ur dialogues then drag n drop it to playmaker fsm and use get property/Text area/string[]   and it will give u an arraylist of ur texts that u wrote.

3-u can also use array get next action or typewriter to make ur dialogue system

4-enjoy !!