I have a gameObject called “Shadow”, and I need to be able to change its sprite image from a script.
How do I do that?
I tried doing that, but I don’t know how to edit Sprite objects:
public Sprite direction;
void FixedUpdate () {
direction = shadow_1(UnityEngine.Sprite);
gameObject.GetComponent<SpriteRenderer().sprite=direction;
}
public Sprite otherSpr;
GetComponent<SpriteRenderer>().sprite = otherSpr;
Throw a sprite into otherSpr in the Inspector and that other line will do the job.
Jay
1 Like