56 lines
1.2 KiB
C#

using System;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using Assets.Scripts.UI.Control;
using Assets.Scripts;
public class MultiTips:PFUIText
{
private Button button;
private string[] tips { get; set; }
private int currentIndex = 0;
private System.Random random;
new void Awake()
{
base.Awake();
text = GetComponent<Text>();
var result = ConfigHelper.mapApi.GetTipsList();
if (result.result)
{
tips = result.data.ToArray();
}
random = new System.Random();
currentIndex = random.Next(0, tips.Length);
SetText();
}
// Start is called before the first frame update
new void Start()
{
base.Awake();
}
public void SetText()
{
if(text == null || tips.Length == 0)
{
return;
}
currentIndex = random.Next(0, tips.Length);
if (currentIndex <= tips.Length)
{
text.text = tips[currentIndex];
}
}
float time = 10f;
// Update is called once per frame
void Update()
{
time -= Time.deltaTime;
while (time<0)
{
SetText();
time += 10f;
}
}
}