28 lines
763 B
C#
28 lines
763 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LayoutCompooment : MonoBehaviour
|
|
{
|
|
public RectTransform rectTransform;
|
|
public GameObject secondMenu;//二级菜单的父类
|
|
public Toggle firstToggle;//一级菜单
|
|
|
|
private void Start()
|
|
{
|
|
firstToggle.onValueChanged.AddListener((canOpen) =>OpenSecondMenu(canOpen));
|
|
}
|
|
public void OpenSecondMenu(bool canOpen)
|
|
{
|
|
secondMenu.gameObject.SetActive(canOpen);
|
|
StartCoroutine(UpdateLayout(rectTransform));
|
|
}
|
|
//写一个鬼携程让UI实时刷新
|
|
IEnumerator UpdateLayout(RectTransform rect){
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
|
|
yield return new WaitForEndOfFrame();
|
|
|
|
}
|
|
}
|