1234567891011121314151617181920212223242526272829303132333435363738 |
- using UnityEngine;
- namespace Plugins.CxShine.ScrollBackgroud
- {
- public class ScrollBackground : MonoBehaviour
- {
- public RectTransform mosaique;
- [Range(0.001f, 0.01f)] public float speed = 0.001f;
- public float lerpDuration = 3;
- private Vector2 destination;
- private Vector2 startpos;
- private float timeElapsed;
- // Start is called before the first frame update
- private void Start()
- {
- startpos = mosaique.localPosition;
- destination = new Vector2(startpos.x - 100f, startpos.y - 100f);
- }
- // Update is called once per frame
- private void Update()
- {
- if (timeElapsed < lerpDuration)
- {
- //mosaique.position = startpos + (Vector3.left * newPos);
- mosaique.localPosition = Vector2.Lerp(startpos, destination, timeElapsed / lerpDuration);
- timeElapsed += 0.001f;
- }
- else
- {
- timeElapsed = 0f;
- }
- }
- }
- }
|