Created
May 29, 2022 03:36
-
-
Save deadasadodo/3900c323d7f42ea0f4f8d985479f17ba to your computer and use it in GitHub Desktop.
This file contains 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class movebackground : MonoBehaviour | |
{ | |
private Renderer renderer; | |
public float scrollSpeed = .1f; | |
void Start() | |
{ | |
renderer = GetComponent<Renderer>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
float x = Mathf.Repeat(Time.time * scrollSpeed, 1); | |
Vector2 offset = new Vector2(x, 0); | |
renderer.sharedMaterial.SetTextureOffset("_MainTex", offset); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment