NaughtyAttributes don't work on custom Inspector Editors
See original GitHub issueNormally if I define a custom PropertyDrawer with an Attribute and apply that Attribute to a field for a MonoBehaviour that has a Custom Inspector and I use EditorGUILayout.PropertyField(field);
do draw that field in the Custom Inspector’s OnInspectorGUI()
then the custom PropertyDrawer will still be used for that field in the Custom Inspector.
If I apply a NaughtyAttributes Attribute like ShowIf
to a field in a MonoBehaviour then it draws as expected with the Default Inspector but if I have a Custom Inspector and draw that field with EditorGUILayout.PropertyField()
it won’t use the custom NaughtyAttributes PropertyDrawer. Is there any way to get this to work inside a Custom Inspector?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
NaughtyAttributes 2.1.4 documentation
NaughtyAttributes is an open-source extension for the Unity Inspector. ... The attributes that won't work in your custom editors are the Meta Attributes...
Read more >dbrizov/NaughtyAttributes: Attribute Extensions for Unity
NaughtyAttributes is an extension for the Unity Inspector. ... The attributes that won't work in your custom editors are the meta attributes and...
Read more >If you are like me tired of writing custom inspectors, try ...
If you are like me tired of writing custom inspectors, try Naughty Attributes. It's incredibly powerful, free and open source.
Read more >How to get button shown in the inspector for method ...
I create instance of it in editor time. ... atrribute class and custom property drawer but I am not sure how to get...
Read more >Discussion - to beautify the inspector
Naughty Attributes is useful for simple inspector stuff. If you need heavily involved custom editor work - and lets be real, every project ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in version 2.0.0. The attributes are now reimplemented with Unity’s CustomPropertyDrawer so they work in custom inspectors. There are some exceptions, however (like ReorderableList, EnableIf…). For these to work you need to call
NaughtyEditorGUI.PropertyField_Layout
instead ofEditorGUILayout.PropertyField
when you are creating your custom editorsHope this is not off topic: Only an incomplete solution, but I managed to get Attributes working in my custom editor by using NaughtyAttributes.InspectorEditor as base class. Only thing is that I needed to make InspectorEditor.OnEnable “protected virtual” so I could override. In my custom editor I override OnInspectorGUI and do what I need after base.OnInspectorGUI().