Projet-IA-Madelaine/Scripts/MainMenuUI/ScrollingTexture.cs
2024-06-12 21:03:42 +02:00

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;
}
}
}