CQ_Intelligent-Technology-T.../Assets/Scripts/康养仿真/TipMangner.cs

81 lines
1.6 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class TipMangner : MonoBehaviour
{
/// <summary>
/// 存放的字
/// </summary>
public List<string> tips = new List<string>();
/// <summary>
/// 显示的文本内容
/// </summary>
public TextMeshProUGUI text;
/// <summary>
/// 下一个按钮
/// </summary>
public Button Next_BTn;
/// <summary>
/// 上一个按钮
/// </summary>
public Button Prev_BTn;
private int index = 0;
// Start is called before the first frame update
void Start()
{
Next_BTn.onClick.AddListener(() =>
{
Next();
});
Prev_BTn.onClick.AddListener(() =>
{
Prev();
});
}
/// <summary>
/// 上一步按钮
/// </summary>
public void Prev()
{
index--;
if (index == 0)
{
index = 0;
Prev_BTn.gameObject.SetActive(false);
}
if (index >= 0)
{
Next_BTn.gameObject.SetActive(true);
text.text = tips[index];
}
}
/// <summary>
/// 下一步按钮
/// </summary>
public void Next()
{
index++;
if (index < tips.Count)
{
Debug.Log(index);
Prev_BTn.gameObject.SetActive(true);
text.text = tips[index];
}
if (index >= tips.Count - 1)
{
Next_BTn.gameObject.SetActive(false);
index = tips.Count - 1;
}
}
}