WooshiiDev / HierarchyDecorator

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

Bug - Settings object reference not found #42

Closed Vacui closed 2 years ago

Vacui commented 3 years ago

Current Unity version used 2018.4.24f1

Describe the bug After installing the plugin using the .unitypackage provided with the release 0.8.4, I found out that the script is unable to detect the ScriptableObject containing the Settings. A NullRefereceException is printed in the console, originated on the GetOrCreateSettings function.

To Reproduce (If applicable) The plugin works perfectly fine in a 2018.4.24f1 project, therefore I'm not aware of a way to reproduce this problem.

Screenshots Screenshot 2021-10-14 at 08 44 15

Additional context The project I'm working is big and complex, I can't exclude the possibility that this problem is originated by other scripts' behaviours.

Vacui commented 3 years ago

After testing the same problem on a clean project in 2018.4.24f1, and seeing the plugin working perfectly find,I can say the problem is originated from something in my own project. I will try to uninstall the plugin again, and running a few more tests, to see if the problem persists.

I updated the original post removing the "reproduce" part.

Vacui commented 3 years ago

I found the culprit of the error. When calling the method AssetUtility.FindOrCreateScriptable, the value passed as type name was "Settings", and I already had a class with that name in another namespace. To fix the problem I changed the value of the constant _SETTINGS_TYPESTRING in HierarchyDecorator from "Settings" to "HierarchyDecorator.Settings", to avoid the collision.

WooshiiDev commented 3 years ago

Hey there Vacui, appreciate the report. We've had an issue report about a month ago in #40 as it conflicts with FMOD. I had to take some time away from working on this, but I should have a fix for this within the next few days.

Vacui commented 3 years ago

While working on the fix I found another problem. The constant _SETTINGS_TYPESTRING is also used to name the Settings file, therefore you have to make this changes if you want to maintain the name:

On HierarchyDecorator.cs

On AssetUtility.cs

I hope it helps

WooshiiDev commented 3 years ago

I've pushed a fix to the branch v0.8.5 in the commit 0053eb7 that fixes this problem.

Now, it checks for the specific setting type - which is something it should have done already - as well as checking all assets named "settings".

I'm not pushing it to the main branch yet as there's some other bugs I want to address but it's available on the branch mentioned above if you want to investigate yourself.

I'll keep this open for the time being until it's pushed to main in case of any problems that crop up.

Vacui commented 3 years ago

It seems it is working for the time being, thx for the quick fix.

WooshiiDev commented 3 years ago

Ah fantastic, great to know it's been fixed. I'm sorry it's not on the main branch yet, other work has been busy, will be back on this soon 🙂

WooshiiDev commented 2 years ago

Hi Vacui, I've released a fix for this in v0.8.5. As this seems to be fixed, I'm going to close the issue, however if there's any further issues please feel free to reply to this issue and I'll reopen it 🙂