35 lines
761 B
C#
35 lines
761 B
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class NPCScript : MonoBehaviourSingletonTemplate<NPCScript>
|
||
|
|
{
|
||
|
|
public UILabel[] labels;
|
||
|
|
int m_index = 0;
|
||
|
|
|
||
|
|
private void OnEnable()
|
||
|
|
{
|
||
|
|
m_index = 0;
|
||
|
|
for (int i = 0; i < labels.Length; i++)
|
||
|
|
{
|
||
|
|
labels[i].text = "";
|
||
|
|
labels[i].alpha = 1f;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Set_Msg(string msg)
|
||
|
|
{
|
||
|
|
labels[m_index].text = msg;
|
||
|
|
StartCoroutine(Co_Msg(m_index++));
|
||
|
|
}
|
||
|
|
|
||
|
|
IEnumerator Co_Msg(int index)
|
||
|
|
{
|
||
|
|
yield return new WaitForSeconds(10f);
|
||
|
|
while (labels[index].alpha > 0f)
|
||
|
|
{
|
||
|
|
labels[index].alpha -= Time.deltaTime;
|
||
|
|
yield return null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|