NG_/预制体/渲染后整体打包/AutoZH.cs
2024-12-13 18:49:44 +08:00

44 lines
1.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class AutoZH : MonoBehaviour,IPointerClickHandler
{
public List<GameObject> zhList;
private int index = 0; // 设置当前菜单索引
// Start is called before the first frame update
private void OnEnable()
{
StartCoroutine(MouseIdleCoroutine());
}
public void OnPointerClick(PointerEventData eventData)
{
// StartCoroutine(MouseIdleCoroutine());
}
private IEnumerator MouseIdleCoroutine()
{
while (true)
{
if (index >= zhList.Count)
{
index = 0; // 回到第一个菜单
}
PointerEventData pointerEventData = new PointerEventData(EventSystem.current);
GameObject mGameObject=zhList[index]; // 获取当前菜单对象
mGameObject.GetComponent<ZHMenuView>().OnPointerClick(pointerEventData);
mGameObject.GetComponent<isRead>().OnPointerClick(pointerEventData);
index++; // 切换到下一个菜单
// 等待指定的闲置时间
yield return new WaitForSeconds(15f);
}
}
}