36 lines
740 B
C#
36 lines
740 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class MarqueeText : MonoBehaviour
|
|
{
|
|
public float speed = 50f;
|
|
public float resetOffset = 500f;
|
|
public float waitTime = 1.0f;
|
|
|
|
private RectTransform rect;
|
|
private float waitTimer = 0f;
|
|
|
|
void Start()
|
|
{
|
|
rect = GetComponent<RectTransform>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
|
|
if (waitTimer > 0f)
|
|
{
|
|
waitTimer -= Time.deltaTime;
|
|
return;
|
|
}
|
|
|
|
rect.anchoredPosition += Vector2.left * speed * Time.deltaTime;
|
|
|
|
if (rect.anchoredPosition.x <= -resetOffset)
|
|
{
|
|
rect.anchoredPosition = new Vector2(resetOffset, rect.anchoredPosition.y);
|
|
waitTimer = waitTime;
|
|
}
|
|
}
|
|
}
|