Advertisement

unity-Ugui-伸缩缩菜单显示固定内容

阅读量:
复制代码
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    
    public class demo1 : MonoBehaviour {
    private List<GameObject> _btnlist = new List<GameObject>();//同级按钮组
    public Transform tf;//按钮的父对象
    void Start () {
        for (int i = 0; i < tf.childCount; i++)
        {
            GameObject tempBtn = tf.GetChild(i).gameObject;
            tempBtn.GetComponent<Button>().onClick.AddListener(delegate { _onClick(tempBtn.gameObject); });
            tempBtn.transform.Find("Content").gameObject.SetActive(false);

全部评论 (0)

还没有任何评论哟~