U
U
Uncle Bogdan2021-07-08 14:35:08
C++ / C#
Uncle Bogdan, 2021-07-08 14:35:08

How to show rewards knocked out of the chest?

A chest opens, rewards fall out of it, it is necessary that at the end it shows all the rewards that are.

I have a class in code with variables and reward sheets. I don't know how to display it in ui. The code already contains the number of coins, experience with an indication of the amount and a link to the character, a link to a new character, there is also a bonus drop in the form of diamonds.

There are already all the values, I want to know how it all is on ui something like this:

60e6e2da3ef7c059340348.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AnanasikDev, 2021-07-08
@motkot

Just make a prefab for the "card" (element), create it from the code in the right place, change the parameters and that's it. You can do this in a loop, in the same place, based on the current index, change the position
Something like:

[SerializeField] Item itemPrefab;
[SerializeField] Transform Canvas;
Item[] itemsGot;
void DrawAll()
{
 for (int i = 0; i < itemsGot.Length; i++)
 {
 Item item = Instantiate(itemPrefab, new Vector2(300 + i*80, 500), Quaternion.identity, canvas).GetComponent<Item>();
 item.params = itemsGot[i].params;
 }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question