- Home /
How to change the scale of a sprite from the c# script?
The scenario is the user hits a coin and the coin text above them gets bigger, bolder, and glows yellow for 1 second to emphasize that a coin was collected. I've dabbled in animations/animators but still have no idea what's going on.
My question is how do you alter a sprites size and color in the script, and if it's better to make an animation and then just call the animation in the script.
Answer by giveson · Dec 30, 2018 at 09:27 PM
Also i recommend watching Arshel tutorials Unity 5 C# Script to change text, text Color, text fontSize if you want to call an animation simply make a variable: public animation (any name);
void CollectCoin() { anim.Play("name of animation goes here"); } if you want to change text you do this: public Text (any name); //this is the text in the scene public int (any name); //this is to change text size public string (any name); //this is to change what the text says public Color (any name); //this is to change text colour
void Changetext() { (text name).text = new string (text name).color = new colour (text name).textsize = new size }