Question by
skoteskote · Oct 20, 2019 at 05:25 PM ·
uiscalingrecttransform
Set value of rect transform to eg Width / 2
Is there a way to set the Left / Top / Right / Bottom values of a Rect Transform to ScreenWidth/2, so it stays constant over different resolutions?
I just want a UI element to cover exactly half of the screen regardless of resolution. I guess it's possible to script it, but how do I access e.g. the Left component of a rect transform? This doesn't work:
gameObject.GetComponent<RectTransform>().rect.xMin = Screen.width / 2;
Comment