summaryrefslogtreecommitdiff
path: root/Thronefall_1_57/Thronefall/FlatKit/UvScroller.cs
blob: e3ab4a37b3913f5086d533668ad690fa0b6ce732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using UnityEngine;

namespace FlatKit;

public class UvScroller : MonoBehaviour
{
	public Material targetMaterial;

	public float speedX;

	public float speedY;

	private Vector2 offset;

	private Vector2 initOffset;

	private void Start()
	{
		offset = targetMaterial.mainTextureOffset;
		initOffset = targetMaterial.mainTextureOffset;
	}

	private void OnDisable()
	{
		targetMaterial.mainTextureOffset = initOffset;
	}

	private void Update()
	{
		offset.x += speedX * Time.deltaTime;
		offset.y += speedY * Time.deltaTime;
		targetMaterial.mainTextureOffset = offset;
	}
}