Advertisement
ThatGuyGilby

Untitled

Aug 16th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class SwitchSprite : MonoBehaviour {
  6. public Sprite[] baseSprites;
  7. public Sprite[] replaceSprites;
  8.  
  9. void LateUpdate () {
  10. for (var i = 0; i < baseSprites.Length; i++) {
  11. if (gameObject.GetComponent<SpriteRenderer>().sprite == baseSprites[i]) {
  12. gameObject.GetComponent<SpriteRenderer>().sprite = replaceSprites[i];
  13. }
  14. }
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement