22 lines
576 B
C#
22 lines
576 B
C#
using UnityEngine;
|
|
|
|
public class parallax : MonoBehaviour
|
|
{
|
|
public Material material;
|
|
public float SpeedMult = 1;
|
|
public float Speed = 10;
|
|
public float distance = 2;
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
material = GetComponent <MeshRenderer>().sharedMaterial;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
distance += Time.deltaTime * Speed * SpeedMult;
|
|
material.SetTextureOffset("_BaseMap",Vector2.right * distance);
|
|
}
|
|
}
|