EmoteChanger.cs (1390B)
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 public class EmoteChanger : MonoBehaviour 6 { 7 private GameObject activeObject; 8 9 // Update is called once per frame 10 public void SetSprite(int index) { 11 ClearSprite(); 12 switch (index) { 13 case 0: 14 activeObject = transform.GetChild(0).gameObject; 15 break; 16 case 1: 17 activeObject = transform.GetChild(1).gameObject; 18 break; 19 case 2: 20 activeObject = transform.GetChild(2).gameObject; 21 break; 22 case 3: 23 activeObject = transform.GetChild(3).gameObject; 24 break; 25 case 4: 26 activeObject = transform.GetChild(4).gameObject; 27 break; 28 case 5: 29 activeObject = transform.GetChild(5).gameObject; 30 break; 31 case 6: 32 activeObject = transform.GetChild(6).gameObject; 33 break; 34 default: 35 activeObject = transform.GetChild(7).gameObject; 36 break; 37 } 38 if (activeObject != null) { 39 activeObject.SetActive(true); 40 } 41 } 42 43 public void ClearSprite() { 44 if (activeObject != null) { 45 activeObject.SetActive(false); 46 } 47 } 48 }