我有以下代码,它使用Quad制作了一个滚动背景。我的问题是如何在一定时间后停止背景的滚动。例如,我希望在滚动图像到达末尾后,最后可见的部分被锁定为其余级别的背景。由于我的玩家速度恒定,我想象中可能会出现这样的情况:在大约20秒后停止滚动并保持图像。我真的很新手Unity,不确定如何做,也没有找到有效的方法。感谢您的帮助!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BG : MonoBehaviour
{
public float speed;
void Start()
{
}
void Update()
{
Vector2 offset = new Vector2(0, Time.time * speed);
GetComponent<Renderer>().material.mainTextureOffset = offset;
}
}