mackysoft / Unity-SerializeReferenceExtensions

Provide popup to specify the type of the field serialized by the [SerializeReference] attribute in the inspector.
https://qiita.com/makihiro_dev/items/26daeb3e5f176934bf0a
MIT License
763 stars 58 forks source link

Property Height Not Updating Immediately [BUG] #9

Closed chadefranklin closed 2 years ago

chadefranklin commented 2 years ago

What happened?

When drawing an array of serializable classes (as SerializeField) that contains a SubclassSelector, the property height does not update immediately when changing the type. The weird part is that logging "Debug.Log(EditorGUI.GetPropertyHeight(property,true));" did show it updating immediately. I also wrote my own Custom Property Drawer which does not have this issue, though I cannot figure out why. I have attached a video of the issue.

https://user-images.githubusercontent.com/55667412/160409770-6fb587dd-0f7f-4e1d-85c9-cc87f00fc8b9.mp4

Here is a video of my version without the issue:

https://user-images.githubusercontent.com/55667412/160416646-7cf68072-912b-4ce7-b006-d05c94a9d0d9.mp4

and the code:

https://gist.github.com/chadefranklin/cd2e6c4d89928ce25274395ff8690f9a

Package Version

1.1.2

Unity Version

2020.3.30f1

mackysoft commented 2 years ago

I have tried to reproduce the problem on my end, but could not.

One possibility is that the process is delegate when the item is selected and is out of the PropertyDrawer.OnGUI cycle, so it is not redrawing properly. image


The following file is the unitypackage for this branch. In this package, serializedObject.Update() is called when an item is selected.

This may solve the issue.

SerializeReference-Extensions.zip

chadefranklin commented 2 years ago

Thanks for the help, that may have solved it though I can't tell as I did update my project to 2020.3.32 and this was in the release notes for 2020.3.31:

image

I'll close the issue though as the problem is resolved.