26 lines
689 B
C#
26 lines
689 B
C#
|
|
using UnityEngine;
|
|
|
|
public class ScrollingTexture : MonoBehaviour
|
|
{
|
|
[SerializeField] private float scrollSpeedX;
|
|
[SerializeField] private float scrollSpeedY;
|
|
private CanvasRenderer canvasRenderer;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
canvasRenderer = GetComponent<CanvasRenderer>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
Vector2 textureOffset = new Vector2(Time.realtimeSinceStartup * scrollSpeedX, Time.realtimeSinceStartup * scrollSpeedY);
|
|
|
|
if(canvasRenderer.GetMaterial() != null) {
|
|
canvasRenderer.GetMaterial().mainTextureOffset = textureOffset;
|
|
}
|
|
}
|
|
}
|
|
|