WooshiiDev / HierarchyDecorator

Lightweight Unity Plugin transforming the Hierarchy into what it should be. Adds headers, styles, icons and more.
MIT License
1.02k stars 47 forks source link

Fix: NullException on Missing Script Components #92

Closed Podden closed 1 month ago

Podden commented 1 month ago

Missing Script Components on GameObjects throw NullException when UpdateActiveState is called, resulting in a broken Hierarchy Window from this GameObject onward

Podden commented 1 month ago

I found this bug but don't know if this is the right place to fix. grafik

WooshiiDev commented 1 month ago

Nice find, massive thanks 🙏

The IsNullComponent property should probably be checking if Type is null rather than having a manual assignment: public bool IsNullComponent => Type == null.

Would you be able to make another commit changing it to that and then using that in place of the fix? This will encapsulate the check for easy reuse.

I can also merge in and then modify afterwards to be as such (but would rather you have credit)

WooshiiDev commented 1 month ago

At some point I should maybe revise how Item types are evaluated as valid so there aren't as many checks all over the place

Podden commented 1 month ago

I've picked a different apporach for performance reasons. You're checking the component for null only once so it seems okay to check the type only one as well and not on every IsNullComponent Call. If you're not okay with this, feel free to implement it yourself, I don't mind not getting credit ;)

Podden commented 1 month ago

I've found another problem: The Scene get's dirtied every frame as soon as there is a gameobject with a component on it (except Transform). I've pushed a fix for that but don't know all the implications when I moved the SetDirty Call to SetActive instead of UpdateActiveState. Maybe you could have a look as well.

WooshiiDev commented 1 month ago

Apologies for the delay - I've been trying to speed up time with this but actual work kinda makes it a bit troublesome. I'll push this in appreciate it! 🙏