- Home /
How can I see the size of a UI element in the editor?
With a UI element's rect transform, you can see the width and height in some circumstances and you can see "right" and "bottom" in other circumstances depending on the anchors you've set. Here's an example of both:
You can see that instead of setting the width, I am able to set the distances from the left and right anchors. This is great, but what if I still want to be able to see what the width of my rect transform has ended up as according to the left and right values I've set?
To be extra clear, I am not asking how to change the anchors so that I'm able to set the width directly like I can with the height. I know how to do that, and I like the anchors the way they are. I'm asking how to see the width in a situation like this where I can't set the width directly. Right now I have to sort of guess based on the dimensions of a parent element, and that's tricky when I have to go several layers up because the direct parent also doesn't have a directly-set width.
Not a nice solution if it's something you want to inspect often, but you can see the width and height by temporarily changing the anchors (so that $$anonymous$$ and max are the same for each of x and y). Just like they are for y in this case.
Answer by JedBeryll · Nov 20, 2017 at 09:12 PM
You can't see those values if you set the anchors like this. 1 way is switch to another mode or write a script (marked ExecuteInEditMode) that displays and sets the width / height.
I suppose writing a script is a good idea. Is it possible to write a script that alters the way a Rect Transform is drawn in the inspector?