infinityUI.cs 651 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class infinityUI : MonoBehaviour
  5. {
  6. public float speed;
  7. public RectTransform panel;
  8. public Vector2 curPosition;
  9. public Vector2 curSize;
  10. private void Start()
  11. {
  12. panel.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width * 2);
  13. }
  14. public float curX;
  15. void FixedUpdate()
  16. {
  17. curX += Time.deltaTime * speed;
  18. curPosition = panel.localPosition;
  19. curSize = panel.sizeDelta;
  20. if(curX >= Screen.width) { curX = 0; }
  21. panel.anchoredPosition = new Vector2(-curX, 0);
  22. }
  23. }