Unity3D — — UGUI之RectTransform

Mask.GetComponent<RectTransform>().anchoredPosition(子物体) = hotKey_image.rectTransform.anchoredPosition(父物体);
Mask.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, hotKey_image.GetComponent<Image>().GetPixelAdjustedRect().width);
Mask.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, hotKey_image.GetComponent<Image>().GetPixelAdjustedRect().height);

以上代码就能让两张图片大小一样并且重合,可以用来让子物体填充父物体或者作为遮罩

猜你喜欢

转载自www.cnblogs.com/QQW123/p/9784974.html