I’m currently experimenting with some custom inspector controls and wondered how I could get the Inspector width. Is this possible?
I’m currently experimenting with some custom inspector controls and wondered how I could get the Inspector width. Is this possible?
As far as I know there’s only this, ugly, way.
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.
– anon73820239The 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.
– DemigiantFor me the hack doesn't work. It return 1 as width during Layout event.
– Paulius-LiekisAfter thinking about it for a while: it makes sense, Unity doesn't know width before it knows full height (it doesn't know if it will need scrollbar or not), so it can not know width before it is done with layouting.
– Paulius-LiekisDo 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.
– wickedroar