using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class MenuMain : MonoBehaviour, IPointerClickHandler { public GameObject menu; // Start is called before the first frame update void Start() { } public void OnPointerClick(PointerEventData eventData) { // 获取当前对象的 Transform 组件 Transform parentTransform = menu.transform; // 遍历并打印所有子对象 for (int i = 0; i < parentTransform.childCount; i++) { parentTransform.GetChild(i).gameObject.SetActive(false); } parentTransform.GetChild(0).gameObject.SetActive(true); //print(parentTransform.GetChild(0).gameObject); } }