- Home /
How to spawn an 2D sprite with a button
I'm new to coding and using unity and I was wondering if there was any way to make a button spawn in a 2D sprite when you click on it and how would you make it a random size and color!
Answer by Vannerss · Apr 01 at 03:38 AM
Instead of "spawning" the button, try making it a object that is disable until you need it, just before you enable the button change the properties of the button so that when it appears it has a random color.
About size and color, the button size property is a float you can use rand.range(numbers you want) to change the size. And for the colors you will have to change the RGB values individually if I'm not mistaken.
There might be better solutions to this but i hope my top of my head written on a cellphone answer can give you some pointers on finding the right answer.
No, i was thinking like you use a ui button to spawn a sprite like a circle or square
Your answer
Follow this Question
Related Questions
How to make UI buttons so my player can move along certain lines 0 Answers
UI Button and character actions 1 Answer
How to make a button animation in menu 1 Answer
UI button not working 1 Answer