Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: miilktea on December 10, 2018, 10:57:35 PM

Title: Displaying Array Strings on UI?
Post by: miilktea on December 10, 2018, 10:57:35 PM
Hi. I'm new to using arrays so I'm a little confused. Basically for my game the player collects objects with a string, and I'd like for the player to be able to view all these strings that they've collected in a UI menu.

So to do this I added these strings into an array, but I'm not sure how to display them on UI. Any pointers would be helpful.

Thanks!
Title: Re: Displaying Array Strings on UI?
Post by: djaydino on December 11, 2018, 02:12:45 AM
Hi.
You will need 2 arrays, 1 with the strings and one with the ui text objects

Then you will need to make a loop on the string array by using 'Array Get Next'.
Store the index and use the index to get the ui object on the 2nd array by using Array Get.
When you got the  ui object use 'Ui Text Set Text' to set the text to that object,
Then loop back to the state with the 'Array Get Next'.

If you want the text list to grow dynamically :
Make a prefab from a ui text object.
On the 'Array Get' set an event on the 'Index Out Of Range'
on the state connected to the 'Index Out Of Range', create or pool the prefab and store the object.
then use the 'UI Text Set Text' and also use 'Array Add' to add the new ui text object to the 2nd array.
Then loop back to the state with the 'Array Get Next'.

Let me know if you understand and got it to work, if not i will try to make a video on it
Title: Re: Displaying Array Strings on UI?
Post by: miilktea on December 11, 2018, 11:18:27 PM
Thanks for the detailed reply! I'll try it out and get back to you.  :)