mmorpg2d/Assets/Lana Studio/Casual RPG VFX/Scripts/UVscroll.cs
2024-08-27 21:01:33 +05:30

32 lines
772 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UVscroll : MonoBehaviour
{
// Scroll main texture based on time
public int materialId = 0;
public float scrollSpeedX = 0.5f;
public float scrollSpeedY = 0.5f;
Renderer rend;
void Start()
{
rend = GetComponent<Renderer>();
}
void Update()
{
//GetComponent<LineRenderer>().materials[0].
float offsetX = Time.time * scrollSpeedX;
float offsetY = Time.time * scrollSpeedY;
rend.materials[materialId].SetTextureOffset("_MainTex", new Vector2(offsetX, offsetY));
//rend.material.SetTextureOffset("_MainTex", new Vector2(offsetX, offsetY));
}
}