Code Clean Up

Override the Get Property Height Method. When using Property Drawers.

James Lafritz
3 min readMay 7, 2021

I went to go edit my enemy to add a shield to it. When I went to change the value for the Shield Health on Damageable Component, I realized that there was something wrong, the Parameter is not being displayed in the editor correctly.

I need to be able to use the Stat Reference without creating a ScriptableObject Variable. In order to display the values of the Constant Value I have to tell the Variable Reference Property Drawer to display the children if using the constant.

Now this gives me a separate problem.

One would think that just changing the height of the position should fix the issue. No matter how I manipulated the position rectangle I could not get the Stat to display properly. After Some research I found an article that had the same exact problem.

Just try and remember to override the GetPropertyHeight function.

So I Override the GetPropertyHeight in the StatReferenceDrawer. I set the total height to be the height of the property with the label. I then get the use constant serialized property. If it is not null and the value is false I return the total line height that was already calculated. If I am still in the method I get the constant value serialized property. I set the total height to the number of visible properties multiplied by the height of the Editors single line height.

Now I can set the Constant Value of the Stat reference variable and everything is displayed properly.

Now that I have everything working I move the code for getting the height into the Variable Reference Property Drawer as a static method, this is so I don’t have to repeat the code in another type of ScriptableObject Reference that is more then just a simple value.

--

--

James Lafritz

Excited about changing my hobby into a new carer with GameDevHQ course.