playMaker

Author Topic: Displaying Array Strings on UI?  (Read 329 times)

miilktea

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Displaying Array Strings on UI?
« on: December 10, 2018, 08: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!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4451
    • View Profile
    • jinxtergames
Re: Displaying Array Strings on UI?
« Reply #1 on: December 11, 2018, 12: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
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions

miilktea

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Displaying Array Strings on UI?
« Reply #2 on: December 11, 2018, 09:18:27 PM »
Thanks for the detailed reply! I'll try it out and get back to you.  :)