using System.Collections.Generic; using UnityEngine; namespace UIWidgetsGallery.gallery { public class heroItem : MonoBehaviour { private List items = new List(); private static int _previousHeroType = 0; public static int heroType = 0; void Start() { var cube = transform.Find("Cube").gameObject; var sphere = transform.Find("Sphere").gameObject; var cylinder = transform.Find("Cylinder").gameObject; var capsule = transform.Find("Capsule").gameObject; items.Add(cube); items.Add(sphere); items.Add(capsule); items.Add(cylinder); UpdateItem(); } void UpdateItem() { for (var i = 0; i < items.Count; i++) { items[i].SetActive(i == heroType); } } void Update() { if (heroType != _previousHeroType) { _previousHeroType = heroType; UpdateItem(); } transform.Rotate( 0 * Time.deltaTime, 60f * Time.deltaTime, 0 * Time.deltaTime ); } } }