playMaker

Author Topic: [solved] Carriage return in string: /n and copy from notepad not working.  (Read 3008 times)

createasaurus

  • Full Member
  • ***
  • Posts: 146
Hi,
I have a GUI Text that is updated with Set String Value.  I'd like to do a carriage return or line break, to do multipule lines.

I did a fourm search, and this topic has come up a lot.  There are many answers over the years (see below) none work for me now.  There are even some posts saying that the ones below no longer work.

1.) copy/paste from GUI text
2.) /n
3.) Open notepad, and copy/paste carriage return

Please, is there a current way to do this?  Should I keep trying these, perhaps I am I doing something wrong?

Thank you!!
« Last Edit: September 18, 2015, 02:03:57 PM by createasaurus »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Carriage return in string: /n and copy from notepad not working.
« Reply #1 on: September 17, 2015, 11:22:15 PM »
I need to look into this again, but I believe the behaviour of EditorGUI.TextField changed in Unity 5 no longer allowing /n linefeeds.

I believe EditorGUI.TextArea still allows /n linefeeds.

You can force the text field in an action to use TextArea using the UIHintAttribute:
Code: [Select]
[UIHint(UIHint.TextArea)]      
So, for example, you could edit SetStringValue.cs to add the attribute to stringValue:
Code: [Select]
[UIHint(UIHint.TextArea)]
public FsmString stringValue;

Let me know if this works for you.
I might make this the default for some actions where it makes sense...

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Carriage return in string: /n and copy from notepad not working.
« Reply #2 on: September 18, 2015, 06:09:35 AM »
Thank you for your time on this.
I've tried... but it is still not working.  Here is what I did:

1) I updated the code in SetStringValue.cs

Quote
[RequiredField]
      //[UIHint(UIHint.Variable)]
      [UIHint(UIHint.TextArea)]
      public FsmString stringVariable;
      [RequiredField]
      public FsmString stringValue;
      public bool everyFrame;

2) I have a GUI text.  (Of interest, in the Inspector Text Field, I can use carriage return and it works.  However, I need to be updating this text with Set String Value)

3) I then used Set String Value in the following ways:
/n
//n
\n
Copy/Paste from notepad with line breaks
Copy/Paste from word with line breaks
Copy/Paste from Inspector Text Field with line breaks

None resulted in line breaks or respecting carriage return, when using Set String Value.

I would love to be able use this function if possible.

Gratefully,
createasaurus
« Last Edit: September 18, 2015, 08:18:18 AM by createasaurus »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Carriage return in string: /n and copy from notepad not working.
« Reply #3 on: September 18, 2015, 11:50:56 AM »
The attribute goes on stringValue not stringVariable.
Code: [Select]
[UIHint(UIHint.TextArea)]
public FsmString stringValue;

Make sure you restore [UIHint(UIHint.Variable)] on stringVariable.

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Carriage return in string: /n and copy from notepad not working.
« Reply #4 on: September 18, 2015, 01:58:21 PM »
Thank you.  It works!!!!!!!!!   ;D ;D ;D
« Last Edit: September 18, 2015, 02:04:42 PM by createasaurus »