- Home /
Get Inspector width
I'm currently experimenting with some custom inspector controls and wondered how I could get the Inspector width. Is this possible?
Answer by Joshua · Aug 18, 2011 at 02:56 PM
As far as I know there's only this, ugly, way.
Too bad it's the only way but nevertheless I used it. Thanks
Be sure to put in a feature request! Things like this are usually extremely easy to implement, they just never thought of making the API available.
The ugly way has the big problem that it works 100% only if you call it before any other GUI layouting. Screen.width would be good, but the issue is that it always returns the width including eventual scrollbars. And as far as I know, unless you're using your own ScrollView scrollbars, there is no way to know if they're present or not.
For me the hack doesn't work. It return 1 as width during Layout event.
Do not use the GetLastRect() every update without checking for width == 1. Save a temp variable globally to store GetLastRect width only if it is > 1. For some reason every other update detects the width as 1. Then use the global temp for width rather than getting it directly from GetLastRect.