Answer the question
In order to leave comments, you need to log in
How to make a sprite change in Unity?
All the best! Need help! Started learning Unity and stuck with the first task... There are three buttons (Rock, Scissors, Paper) and there is some invisible GameObject. It is necessary to make it so that when the button is pressed, the object changes its Sprite to the one that lies in a pre-prepared folder. I watched a lot of videos... and I can't figure out how to do it... Please tell me!
public class Button : MonoBehaviour
{
public Sprite Button_stn, Button_scs, Button_pap, GameObj;
public void Button_stn_cl()
{
GameObj = Resources.Load("1") as Sprite;
}
public void Button_scs_cl()
{
GameObj = Resources.Load("2") as Sprite;
}
public void Button_pap_cl()
{
GameObj = Resources.Load("3") as Sprite;
}
public void Game_object()
{
GetComponent<SpriteRenderer>().sprite = GameObj;
}
void Start()
{
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question