Populating UI panels with Text

Hello,

I have a rather vague question. I’m sure that if I knew the proper terms I’d be able to search and resolve this on my own. But I can’t, so I’m here.

I would like to have one generic UI panel that displayed the contents of image and text components that are attached to trigger game objects, ones that when clicked on open the UI panel.

The game I’m working on is an educational type game, so when a player clicks on a certain object I would like a UI panel to appear giving information, basically an info box.

Honestly, I have no idea how to search for this solution so any information is appreciated.

Sincerely,
Nathan

You may need to use world space canvas. Like this:

1 Like

@Zonlib

Thanks for the link, that’s a really great video. There’s a lot of useful little bits in there.

Unfortunately, that’s not really what I was trying to describe. My issue is that I have, say, 100 triggers in a scene. Each trigger corresponds to a UI page that displays information, an image and a brief description of the image.

How I have it now is there are 100 UI panels (they simply get turned on and off when the corresponding trigger is activated. It works but it’s rather cumbersome as I have two folders: one for triggers in the game; and one in the UI Canvas. I need to make sure that each are sync’d.

What I imagine is having one single UI panel that functions as a template and is fed, in real time, the contents from the triggers as they are activated. So the panel would display the info form a text box and image component that is a part of the trigger game object. I’d actually like to get from referencing a database, but baby steps.

But thanks for you response, that video will help with other elements a lot.
Nathan

So, you create a UI template then create a database such as an .xml file that stores the id and image path and information like this:

<imformations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <info id="0" photo_path="photo/thumb1.png" >
      Description 0
  </info>
  <info id="1" photo_path="photo/thumb2.png" >
      Description 1
  </info>
  <info id="2" photo_path="photo/thumb3.png" >
      Description 2
  </info>
</imformations>

When a user clicks on a trigger, the application retrieves the information from the xml file based on the id attribute and loads it into the UI

1 Like

Thanks again, @Zonlib

Out of curiosity, is this your code or is there a link to more information about this? I’m not a strong programmer but if I have examples or materials to work with I can piece my way together. This is exactly what I was hoping to get to eventually, but if I can actually do it now I might as well put my energy into it now.

Thanks again!

Nathan

That is my code. I used to do the same thing and I’m ready to make a tutorial if you need it :slight_smile:

1 Like

Hey, @Zonlib

That is extremely generous of you and would be amazing if it’s not too much work. I should be able to put the pieces together if you just give me the general idea of how to go about this.

For example, one thing that still completely escapes me is to have the content displayed in the generic UI panel.

Let me know if I can help at all or return the favour somehow.

Nathan

Sorry for late @nathanjams
Today I have time to make the promise, hope you still need it.
I made a small video tutorial for you and who needed it.

1 Like

Holy crap! Biduc.

Thank you so much for doing this. Yes, I still have a need for it. I won’t get a chance to tackle this until later in the week, but i’ll let you know how it all goes.

Seriously, seriously, seriously. Thank you.

Nathan

Just a little bump for this thread. This is an awesome example for those unfamiliar with incorporating XML databases into their unity projects. The tutorial is very straightforward and easy to follow and provides you with a very easy to understand foundation for further modification.

Big ups to BiDuc for going way beyond on this.