Files
TaiWan/Assets/Roaming/Scripts/Widget/TextureScroll.cs

39 lines
735 B
C#
Raw Normal View History

2025-10-31 15:20:38 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TextureScroll : MonoBehaviour
{
Material mat;
public float smoothSpeed = 0.1f;
public int scrollSpeed = 5;
int offset;
// Start is called before the first frame update
void Start()
{
mat = this.GetComponent<MeshRenderer>().material;
StartCoroutine(Scroll());
}
IEnumerator Scroll()
{
while (true)
{
offset = (offset + scrollSpeed) % 100000;
mat.mainTextureOffset = new Vector2(offset / 100000f, 0f);
yield return new WaitForSeconds(smoothSpeed);
}
}
void OnMouseDown()
{
// Debug.Log("A");
}
}