playMaker

Author Topic: [SOLVED]Problem to Store a String or UI Text  (Read 686 times)

AxelG

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
[SOLVED]Problem to Store a String or UI Text
« on: November 12, 2019, 11:01:51 AM »
Udpate:

Hello, I'm updating the topic since I still have some issues with my method.

Still with the same text, I have to display it on a different text object in a different Canvas for screen scaling/ fitting reasons.

The stored text is displayed correctly but a one moment, it switch back to the first text stored even if the stored text correctly set-up.

Here is a video:


I don't understand why.

-----------------------
Hey there,

I'm having issues with the get and set UI Text actions. I'd like to store the Text content of a Text component to display it on an other object's Text component.
I use a Global Variable to store the text but when testing, it kind of work randomly.

First Image:
It's the second panel with a different text from the previous but it display the previous panel text.




Second Image:
The following panel displaying the correct text.


Any idea?
« Last Edit: November 17, 2019, 03:32:06 AM by AxelG »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: Problem to Store a String or UI Text
« Reply #1 on: November 12, 2019, 10:56:17 PM »
Hi,

 you likely have a race condition or a conflict between two fsm.

- first, why do you add a component at fsm start? it's going to be more optimal to simply add it manually and be done with it.

- global don't need to be used here, are you familiar with event data?

1: get the text you want to save in a local fsm variable
2: set event data string to this text value
3: send a global event
4: other fsm can catch this event and use GetEventInfos to retrieve the string value

Bye,

 Jean

AxelG

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
Re: Problem to Store a String or UI Text
« Reply #2 on: November 13, 2019, 09:44:33 AM »
Hi Jean,

Thank you, like you said it was a race condition.
For the component, I need it in my setup and as it doesn't support Playmaker, I had to edit the default value to what I wanted and have it launch from there so it run correctly.

I use global variable because I need the values to be shared between objects.
I found a solution, though I'm not familiar with event data where can I learn more from it?

Thanks,

Axel

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: Problem to Store a String or UI Text
« Reply #3 on: November 13, 2019, 11:36:07 PM »
Hi,

event data is easy: https://hutonggames.fogbugz.com/f/page?W531

you set event data before the action sendEvent for example, and when you receive that event, you use GetEventInfo to retrieve the data.

so for example, if you want to send an event "ON PLAYER LOGGED IN", you can pass the name of the player

SetEventData - string -> Jean
SendEvent "ON PLAYER LOGGED IN"
on another fsm, you catch "ON PLAYER LOGGED IN"
GetEventInfo - string - >Jean



Bye,

 Jean

AxelG

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
Re: Problem to Store a String or UI Text
« Reply #4 on: November 14, 2019, 07:31:47 AM »
That's quite interesting, thanks a lot Jean.

Best,
Axel

AxelG

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
Re: Problem to Store a String or UI Text
« Reply #5 on: November 15, 2019, 10:59:14 AM »
Hello, I'm updating the topic since I still have some issues with my method.

Still with the same text, I have to display it on a different text object in a different Canvas for screen scaling/ fitting reasons.

The stored text is displayed correctly but a one moment, it switch back to the first text stored even if the stored text correctly set-up.

Here is a video:


I don't understand why.

ch1ky3n

  • Full Member
  • ***
  • Posts: 117
    • View Profile
Re: [Update]Problem to Store a String or UI Text
« Reply #6 on: November 16, 2019, 09:25:31 AM »
Hello Axel,

I tried to watch your videos a couple of time but still couldn’t get it yet, i believe there is a miss in the architecture itself. You have so many FSMs on your hierarchy.

It seems that you have 2 canvas with text objects, name it canvasA and canvasB. You want to display text “number1” on canvasA first, then you display “number1” on canvasB while canvasA display the next text “number2” and so on, is that correct ?

My question is :

1. which FSM changes the Global String of the text ?
2. If there is going to be a lot of text in your game, Have you considered to setup an array for the dialogue?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
    • View Profile
    • jinxtergames
Re: [Update]Problem to Store a String or UI Text
« Reply #7 on: November 16, 2019, 07:33:09 PM »
Hi.
Its also very possible that the Typewriter Text Effect Extended is the issue here.

As when the 2nd time it adds a 2nd 'Typewriter Text Effect Extended component'
and they are conflicting with each other.

So you need to remove the component before 2nd text.

But this is a inconvenient way to do this.

You should try to Disable/Enable the script instead to 'reset' it.

You can find 'activate component' on the Ecosystem

So Deactivate the component, then set text and then activate it.
You might need a next frame in between set text and activate.

AxelG

  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
Re: [Update]Problem to Store a String or UI Text
« Reply #8 on: November 17, 2019, 03:31:45 AM »
@ch1ky3n:

The FSM setup that allow to change the text depends of the current activated panel.
For the string Array, I considered it, but in my project it wouldn't have optimal since some panels don't have text and the text has to be translated too.

@djaydino:

Thanks, the Activated/ deactivate action didn't work, but it hinted me that they was a "remove on exit" on the "add component" action that solved the problem!

Thanks to both of you for your time!

Best,
Axel