Best way to create dynamic text objects with Canvas?
Hi all!
I am building a 2D game where I need to dynamically create different kinds of text objects based on what user does and what the gameobjects do in the game. Text objects present points which users get while playing the game.
I want to display the points next to the corresponding action and gameobject in the game, with a fading animation next to them. After the fade animation is complete, I need to destroy the text objects.
My first solution was to use a simple 2D texture. It was very easy to use and I was able to add the animation to it fairly easily. However, it did not allow me to change the text because it the texture says the same.
I thought that using Unity's UI text would resolve the issue, but I am totally lost with how to use and position them.
I am already using one Canvas (for the general UI) in the game.
Shoud I add these gameobjects with the UI Text component in them to existing Canvas or create a totally new Canvas for them? If the best option is to use exiting Canvas, what is the logic positioning the text components in them? Only thing which I have gotten so far are these huge-ass texts which don't even display on the screen. I see them in Scene-view.
I have tried to set the parent of these gameobjects the already existing Canvas. I have also tried to set the position of the Text gameobject based on the position of the object which is firing them. Neither works and I'm lost with this trench of thought.
Thank you in advance for helping me out! :) - Jukka
Your answer
Follow this Question
Related Questions
Dynamically added UI text is not displaying 2 Answers
UI Canvas Anchor points are stuck in the bottom left corner and disabled when in overlay mode. 1 Answer
How To Load TTF Font From External File 0 Answers
How to make Textmesh Pro effects on only one text object? 1 Answer
OnGUI behind UI? 0 Answers