Custom PropertyDrawer modular width/height

pdabrowski 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 8


I've written a class (non MonoBehaviour deriven), that has a  custom property drawer script, that shows/hides some of it's public fields based on whether other fields are null or not. For example: if you attach a GameObject to a field, then some other variables show up. In the Unity Inspector, it works fine, but when showing in Bolt, I have a visual problem.

The fields show or hide correctly, because as I tested, OnGUI is called as normal. But, I have also overriden the GetPropertyHeight method, which is crucial for resizing the window based on the visible fields - but this method is only called once, just only after script compilation. Because this method is not called, the fields that show up land outside of the node, which hardly functional.

So, my question is: is there a way, to manually call a refresh in Bolt for this particular property drawer logic?

Also, is there any way for modyfing the custom classes width when working with them in Bolt?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Satisfaction mark by pdabrowski 3 years ago

Not exactly sure how you're implementing this, but if you have a Bolt Inspector object, you probably want to call Inspector.SetHeightDirty();

Thank you for the response :)

No, I dont think I have a Bolt Inspector object. I have 2 classes:
- The first contains the data (game objects etc.)
- The second one is inheriting from Unity Editor's PropertyDrawer class, which is my own custom Property Drawer for the first class

What I do, is: 

- Add the first class via Unit Options Wizard

- Generate the custom inspectors via Tools/Ludiq/Generate Custom Inspectors

I attached a file: AnExample with an example of my implementation and some 2 screenshots to summarize my problem.

Hi pdabrowski!

Ok, thanks for the report, I'll look into it. I might have to disable height caching on PropertyDrawer inspector proxies, but it shouldn't be so bad.

Thank you very much for looking into that case.

I would also like to ask, is possible to somehow modify the width for the class inspectors in Bolt? Those variable names can very easily get hidden behind their respective fields.

Fixed in Next Version

So I looked into your issue and I could reproduce it, thanks for the report!

It's a tricky thing to fix, because there is a lot of caching involved in Bolt to make sure we calculate positions as rarely as possible. I did however disable height caching on literals and on custom property drawers, and implemented constant dimensions checking on literal widgets, so it should fix the problem in v1.4.0f10. Hopefully it shouldn't affect the performance too much in other cases.

There was no explicit way of setting the width, but I added an [InspectorAdaptiveWidth] attribute that you could put on your Example class, which will bypass any width limitation.

Results in: 

Note that the [InspectorAdaptiveWidth] attribute will also work with automatic Bolt inspectors (e.g. any type marked with [Inspectable]).

Thank you very much! It worked fine :)