39 lines
735 B
C#
39 lines
735 B
C#
|
|
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");
|
||
|
|
}
|
||
|
|
}
|