27 lines
593 B
C#
27 lines
593 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class SimpleScrollLoop : MonoBehaviour {
|
|||
|
|
|||
|
public float width = 8.75f;
|
|||
|
public float speed = 1f;
|
|||
|
private float value = 0f;
|
|||
|
|
|||
|
public Transform one, two;
|
|||
|
|
|||
|
private void Update() {
|
|||
|
if (speed > 0) {
|
|||
|
one.localPosition = new Vector3(value - width, 0f, 0f);
|
|||
|
two.localPosition = new Vector3(value, 0f, 0f);
|
|||
|
} else {
|
|||
|
one.localPosition = new Vector3(value + width, 0f, 0f);
|
|||
|
two.localPosition = new Vector3(value, 0f, 0f);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
value += Time.deltaTime * speed;
|
|||
|
value %= width;
|
|||
|
}
|
|||
|
}
|