using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using GameFramework.Event; public class FaultChoicesSceneCtrl : MonoBehaviour { public int ObjCount = 8; private GameObject[] _Objects; private void Awake() { _Objects = new GameObject[ObjCount]; for (int i = 0; i < ObjCount; i++) { _Objects[i] = this.transform.GetChild(i).gameObject; _Objects[i].SetActive(false); } } void Start() { GameMain.Event.Subscribe(FaultChoicesChangeEvent.EventId, OnFaultChoicesChange); } private void OnDestroy() { if (GameMain.Event.Check(FaultChoicesChangeEvent.EventId, OnFaultChoicesChange)) { GameMain.Event.Unsubscribe(FaultChoicesChangeEvent.EventId, OnFaultChoicesChange); } } private void OnFaultChoicesChange(object sender, GameEventArgs e) { FaultChoicesChangeEvent args = (FaultChoicesChangeEvent)e; foreach (var obj in _Objects) { obj.SetActive(false); } if (args.changeIndex == -1) { return; } _Objects[args.changeIndex].SetActive(true); } }