using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SceneSlectedWnd : WindowBase { public int currentSlectedIndex = 0; [Header("场景图片")] public Transform sceneImgParent; private Image[] sceneImages; private Image[] scneMiaoBianImgs; [Header("按钮")] public Button EnterBtn; public override void Init() { base.Init(); sceneImages = new Image[sceneImgParent.childCount]; scneMiaoBianImgs = new Image[sceneImgParent.childCount]; for (int i = 0; i < sceneImgParent.childCount; i++) { sceneImages[i]=sceneImgParent.GetChild(i).Find("Image").GetComponent(); scneMiaoBianImgs[i]= sceneImgParent.GetChild(i).Find("miaobian").GetComponent(); UIEventListener listener = sceneImages[i].gameObject.AddComponent(); listener.ID = i; listener.onPointDown = () => { SetSceneIndex(listener.ID); }; } EnterBtn.onClick.AddListener(() => { switch (currentSlectedIndex) { case 0: GameRoot.Instance.SetGameState(GameSateType.塌方巡检); this.gameObject.SetActive(false); break; case 1: GameRoot.Instance.AddTipQueue("此场景开发中"); break; case 2: GameRoot.Instance.AddTipQueue("此场景开发中"); break; case 3: GameRoot.Instance.AddTipQueue("此场景开发中"); break; } }); } public void SetSceneIndex(int index) { currentSlectedIndex = index; for (int i = 0; i < scneMiaoBianImgs.Length; i++) { if (i == index) { scneMiaoBianImgs[i].gameObject.SetActive(true); } else { scneMiaoBianImgs[i].gameObject.SetActive(false); } } } }