How to have a scrolling background quad cycle through tiled materials?
I have a scrolling background images that is set as a material onto a quad. Right now I have the code as listed below, but I need to have the background image swap out with other different background tiles (they're all designed visually to match up seamlessly next to one another).
Any ideas on how to do this?
Thank you!
public class Background : MonoBehaviour
{
// Scroll speed
public float speed = 0.1f;
void Update ()
{
// Value of x change from 0 to 1 by time. return to 0 if it becomes 1 and repeat.
float x = Mathf.Repeat (Time.time * speed, 1);
// Create offset that shift value of x
Vector2 offset = new Vector2 (x, 0);
// Set up offset to materials
GetComponent<Renderer>().sharedMaterial.SetTextureOffset ("_MainTex", offset);
}
}
Comment