Last active
August 12, 2021 17:51
-
-
Save ibra/03a9af05e40cc3a381c9e7a669dfc5cb to your computer and use it in GitHub Desktop.
Infinite Scrolling Material In Unity in 20 Lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace IbraUtils.Scrolling | |
{ | |
public class InfiniteScroll : MonoBehaviour | |
{ | |
private Material _material; | |
private Vector2 _scrollVelocity; | |
[SerializeField] private float xVelocity, yVelocity; | |
private void Awake () => | |
_material = GetComponent<Renderer>().material; | |
private void Start () => | |
_scrollVelocity = new Vector2(xVelocity, yVelocity); | |
private void Update() => | |
_material.mainTextureOffset += _scrollVelocity * Time.deltaTime; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment