how ro automatic scrol text in unity code example
Example: how ro automatic scrol text in unity
[SerializeField, Range(1f, 5f)] private float scrollSpeed = 2f; private float watingTime = 5f; private float maxScroll; private ScrollRect scrollRect; private RectTransform contenRectTransform; private Vector2 defaultPosition; private bool canMove; private void Start() { this.scrollRect = GetComponent<ScrollRect>(); this.contenRectTransform = this.scrollRect.content; this.maxScroll = this.contenRectTransform.rect.yMax; this.StartCoroutine(this.ActivateAutoMove()); } private void Update() { bool hasScrolled = this.contenRectTransform.position.y > this.maxScroll; if (canMove & !hasScrolled) this.Move(); } private void Move() { Vector2 contentPosition = this.contenRectTransform.position; Vector2 newPosition = new Vector2(contentPosition.x, contentPosition.y + this.scrollSpeed); this.contenRectTransform.position = newPosition; }