playMaker

Author Topic: Action to insert line breaks/carriage returns for Strings  (Read 8117 times)

jess84

  • Hero Member
  • *****
  • Posts: 515
Action to insert line breaks/carriage returns for Strings
« on: July 25, 2014, 12:26:19 AM »
It would be useful to have an action where I could select my string, and then be able to add a return character at a given point, in order to have a GUI Text appearing over multiple lines.

I'd like to be able to say "after every n'th character, add a line break". (ideally however not inserting a break in the middle of a word, just in the nearest space)

Is this even possible?

I have Daikon Forge, but at the moment it's pretty unusable on mobile. And before I buy another GUI solution, I'd like to be able to display my text at least semi ok.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Action to insert line breaks/carriage returns for Strings
« Reply #1 on: August 08, 2014, 03:15:52 PM »
Hi,

 simply use "\n" and that will work, this is the code for a return.

else, simply copy paste a return from a regular text file and paste it in a global variable or on a specific action. that works very well too.


 Bye,

 Jean

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Action to insert line breaks/carriage returns for Strings
« Reply #2 on: August 08, 2014, 05:31:54 PM »
\n wouldn't work for me when used in a GUI Text component.

Regardless, this would require manually adding the character - If I've got a text string of 200 characters, and the text might change as I rewrite text, then this isn't practical.

An action for automatically inserting at a designated interval would be much more useful.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Action to insert line breaks/carriage returns for Strings
« Reply #3 on: August 09, 2014, 01:28:57 AM »
Hi,

 yeah, and in that case, simply store the return in a local variable and build your strings the way you want. I do that all the time. no need for an action here in my opinion.

 simply open a text editor and copy 2 empty lines and paste it in your fsm string variable and then you are free to write anything!

 otherwise you can also rely on better UI like Ngui and else where you have a stronger and more powerful text editing built in.

 Bye,

 Jean

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 46
Re: Action to insert line breaks/carriage returns for Strings
« Reply #4 on: May 17, 2015, 03:22:05 PM »
Hi, I know this thread is a little old but does the copy and pasting a return from textedit still work?

As I cannot get it to work and when I insert my "return" character into a string that's  passed to GUI text I just get a space.

Could someone please test in Unity 5 and let me know as it's driving me mad :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Action to insert line breaks/carriage returns for Strings
« Reply #5 on: May 19, 2015, 02:48:37 AM »
Hi,

 funny you say that, I am currently exposing custom actions I find in various projects back to Ecosystem, and I have put 3 new actions:

StringAddNewLine
StringDeleteLine
StringGetLineCount

as for the carriage return, yeah, it's odd I can't get it to work neither...

Bye,

 Jean

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 46
Re: Action to insert line breaks/carriage returns for Strings
« Reply #6 on: May 19, 2015, 08:40:26 AM »
That was perfect Jean. And good timing :)

Thanks,
Philip.

Alatriste

  • Full Member
  • ***
  • Posts: 195
Re: Action to insert line breaks/carriage returns for Strings
« Reply #7 on: September 26, 2015, 06:55:04 AM »
Awesome! Thanks! I was also having some troubles making work the trick of the variable.  ;)

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Action to insert line breaks/carriage returns for Strings
« Reply #8 on: June 03, 2016, 06:21:02 PM »
I am using BUILD STRING and tried \n as separator, but it doesn't work.
Any idea how to make it?

Man these are the things that really put me down... it shouldn't be so difficult to have a new line at all... you can't annoy all the people in need of such a basic function, it's terrible... how could they at Unity overlooked something like this...

Deh, the STRINGADDNEWLINE works for me, thank you!
« Last Edit: June 03, 2016, 07:01:52 PM by megmaltese »