ソースコード
using UnityEngine; public static class RectTransformExt { public static void SetAnchoredPositionX ( this RectTransform self, float x ) { var pos = self.anchoredPosition; pos.x = x; self.anchoredPosition = pos; } public static void SetAnchoredPositionY ( this RectTransform self, float y ) { var pos = self.anchoredPosition; pos.y = y; self.anchoredPosition = pos; } }
使い方
rectTransform.SetAnchoredPositionX( 1 ); rectTransform.SetAnchoredPositionY( 2 );