Unity UI Extensions

SwitchToRectTransform

RectTransform extension method to move one RectTransform to another


Contents

1 Overview

2 Properties

3 Methods

4 Usage

5 Video Demo

6 See also

7 Credits and Donation

8 External links


Overview

A programmatic extension that enables you, through code to move a RectTransform from one point on a screen to another point on the screen using a target RectTransform. This aligns all the Anchors, Pivots and offsets of the Target RectTransform.


Properties

This is a static extension method; there are no inspector properties.


Methods

Method Arguments Description
switchToRectTransform RectTransform source, RectTransform target Moves source to match anchors/pivots/offsets of target in screen space.

Usage

Using this utility through code is very simply, just call:

sourceRectTransform.switchToRectTransform(targetRectTransform);

And the Source (from) Rect Transform will be moved to mimic the Target (to) RectTransform position.


Video Demo

N/A


See also

N/A


Credits and Donation