I’m making a game where you get points when you do certain things. So I want that everytime you make points, it shows it to the player on the Screen. I have been looking for List of strings on google, and studying of GUI in Unity Documentation, but still cant find How to do what I want.
Basically what i want is to show more than one text on screen, but every text can have its own properties.
you can use just one ui text and edit its text via script when points need to be displayed.
yourtext.text = " whatever you want"
then remove the text
outText.text = " ";
you can use a co routine to delay the deletion.
eg
Ienumterator waitToDelete()
{
yourText.text = “whatever”
yield return new WaitForSeconds(3);
yourText.text = " ";
}
But what if I want a list of UI texts… For example: i made +50 points on pos (10,10), a text will appear showing the player a “+50”, and the text will continiously dissapearing and raising until it dissapears, it will take 2 seconds until it totally dissapear, but after a second, the player make +100 points again… the text will appear and dissapear while the +50 is still dissapearing on the screen (sry for my eng).
ok so you have to make a prefab of a ui text object with a script attached that has a public ui text variable with the prefabs text attached. you can then instantiate the prefab over and over with different texts. Its a pretty complicated thing to do. there is a tutorial on the unity youtube channel for instantiating lists at runtime.
this helped me spawning lists at runtime. it is for inventories but it has the same premise.
oh and when settting the parent of a ui you need to do it like this
uiObject.Setparent(parentObject,false)
otherwise for some reason it doesnt rescale to the current res.