You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
897 B
C#
40 lines
897 B
C#
2 weeks ago
|
using UnityEngine;
|
||
|
|
||
|
namespace Unity.BossRoom.VisualEffects
|
||
|
{
|
||
|
public class ScrollingMaterialUVs : MonoBehaviour
|
||
|
{
|
||
|
public float ScrollX = .01f;
|
||
|
public float ScrollY = .01f;
|
||
|
|
||
|
[SerializeField]
|
||
|
Material m_Material;
|
||
|
|
||
|
float m_OffsetX;
|
||
|
float m_OffsetY;
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
m_OffsetX = Time.time * ScrollX;
|
||
|
m_OffsetY = Time.time * ScrollY;
|
||
|
m_Material.mainTextureOffset = new Vector2(m_OffsetX, m_OffsetY);
|
||
|
}
|
||
|
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
ResetMaterialOffset();
|
||
|
}
|
||
|
|
||
|
void OnApplicationQuit()
|
||
|
{
|
||
|
ResetMaterialOffset();
|
||
|
}
|
||
|
|
||
|
void ResetMaterialOffset()
|
||
|
{
|
||
|
// reset UVs to avoid modifying the material file; this will be refactored
|
||
|
m_Material.mainTextureOffset = new Vector2(0f, 0f);
|
||
|
}
|
||
|
}
|
||
|
}
|