In my project I’m making a pause screen with the new UI system. I have an icon that will move around the screen, but I don’t know how to get my icon to size correctly.
As shown in this image: http://imgur.com/2Z7r8Eb I need rectangle A to take on the dimensions of rectangle B so that it will completely overlap it.
How would I do this?
Hmmm, getting late (yet again) where I am but I think I can answer even if sleepy!
Set the anchors to the center of the parent for both objects, then drag the panels onto the public slots of this script:
using UnityEngine;
using System.Collections;
public class MatchSize : MonoBehaviour {
public RectTransform RTB; // the one you want to resize
public RectTransform RTA; // the one you want to copy the size of
// Use this for initialization
void Start () {
RTB.sizeDelta = new Vector2(RTA.rect.width, RTA.rect.height);
RTB.localPosition = RTA.localPosition;
}
}
Sorry if rubbish, it’s late!