using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ParallaxEffect : MonoBehaviour
{
    [SerializeField]
    float p_myScrollSpeed;

    Vector2 p_mySavedOffset;

    void Start()
    {
        p_mySavedOffset = GetComponent<Renderer>().sharedMaterial.GetTextureOffset("_MainTex");
    }

    void Update()
    {
        float x = Mathf.Repeat(Time.time * p_myScrollSpeed, 1);
        Vector2 offset = new Vector2(x, p_mySavedOffset.y);
        GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", offset);
    }
}