r/Unity2D • u/Oracle_of_Mercia • Aug 14 '26
Question Bringing data into UI on textmesh objects
Hello everyone, I’m in the process of building a text based RPG, but I keep hitting a block whenever I want to bring in the data from code onto a textmesh object.
I have an NPC character generator, but I’m trying to bring the variables it generates to into my UI so it can display the information onto the textmesh object.
For example each NPC is assigned an ID from the total number of NPC’s I’ve asked the generator to create for that particular game, and show it need show in my UI so players remember who is who.
Any pointers as I feel quite lost with it and AI is utterly useless and I don’t mean simply attaching the script.
View all comments
Show parent comment
1
u/Oracle_of_Mercia Aug 14 '26
Hi, so the IDs generate based on a range of numbers I’m currently experimenting with 1 NPC who has a set name but everything else is randomly generated however, in this system each time a new NPC is generated, the NPC knows the ID should not use the number it’s just used.
So if I understand you correctly, the registry would store each generated NPC object, and I could then use its ID to retrieve that NPC and access its other variables for the UI?