unity 实现字幕轮播功能
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class lunbo : MonoBehaviour{public float timer = 5.0f;public string[] textStrs = new[] { "如果怪物吃到
·
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class lunbo : MonoBehaviour
{
public float timer = 5.0f;
public string[] textStrs = new[] { "如果怪物吃到电池将会加快移动速度","如果怪物吃到太空人体型将会变大" };
private int textIndex=-1;
public Text text;
void Start()
{
InvokeRepeating(methodName: "ChangeText", time: 0, repeatRate: timer);
}
// Update is called once per frame
void ChangeText()
{
text.text = textStrs[++textIndex % textStrs.Length];
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)