TaiZhouChangChu/Assets/Script/LH/ChatPanel.cs

45 lines
1011 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ChatPanel : MonoBehaviour
{
private int chatIndex = 0;
public List<string> chatContent = new List<string>();
// Start is called before the first frame update
void Start()
{
this.GetComponent<Button>().onClick.AddListener(() => { ChangeContent(); });
}
// Update is called once per frame
void Update()
{
}
public void ShowChatPanel()
{
transform.GetComponentInChildren<Text>().text = chatContent[chatIndex];
chatIndex++;
}
private void ChangeContent()
{
if (chatIndex < chatContent.Count)
{
transform.GetComponentInChildren<Text>().text = chatContent[chatIndex];
}
else
{
//GameMannage.instance.StepAdd();
chatIndex = 0;
gameObject.SetActive(false);
return;
}
chatIndex++;
}
}