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
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
144 People are following this question.
Change UI Text in script
How to render text on top of the objects that are generated on the map using a script?
In updating some score text, why should we use the Update function instead of separate functions?
Can't see Text UI in game view
Text in UI disappears when clicked on