Skip to content

Instantly share code, notes, and snippets.

Created April 11, 2019 11:04
What would you like to do?
Simple Unity3D Scrolling Material Script
using UnityEngine;
public class ScrollingMaterial : MonoBehaviour
public float Speed;
float _uvFactor;
Material _materialToScroll;
void Awake()
_materialToScroll = GetComponent<MeshRenderer>().material;
float n = _materialToScroll.GetTextureScale("_MainTex").y;
float scale = transform.localScale.z;
_uvFactor = n / scale;
void Update()
_materialToScroll.mainTextureOffset = new Vector2(_materialToScroll.mainTextureOffset.x, _materialToScroll.mainTextureOffset.y + Time.deltaTime * Speed * _uvFactor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment