Move UI element from top to bottom of the screen

I wont to move Ui Button from top of the canvas screen to bottom of the canvas screen. After moving outside of canvas(Bottom canvas) it should replace to top of the canvas screen.

Hello, @SaurabhStudio,

Attach this script to the UI Button you want to move. It assumes your Canvas is named “Canvas”.

using UnityEngine;

public class MoveButton : MonoBehaviour {

    RectTransform canvas;
    RectTransform button;
    Vector3 startingPosition;
    public float speed;

    void Start()
    {
        button = gameObject.GetComponent<RectTransform>();
        canvas = GameObject.Find("Canvas").GetComponent<RectTransform>();
        startingPosition = transform.position;
        speed = -10f;
    }

    void Update () {
        transform.Translate(0f, speed, 0f);
        if (button.position.y < -button.rect.height)
            transform.position = new Vector3(startingPosition.x, canvas.rect.height + button.rect.height, startingPosition.z);
	}
}

Hi,

You can move any UI element using script with a coroutine and a MoveTowards method or Lerp, without the disadvantages of using Animator.

I explain how exactly make that in this tutorial:

https://youtu.be/LBoPP9mKjKc