Issue with ShowAssetPreview and SerializeField
See original GitHub issueHey there,
I’ve encountered an issue when using ShowAssetPreview together with SerializeField on a Sprite within a scriptable object.
Here is the line: [SerializeField] [BoxGroup(GENERAL_SETTINGS_HEADER)] [ShowAssetPreview] Sprite itemIcon;
It works when I remove the SerializeField option and use a public modifier instead: [BoxGroup(GENERAL_SETTINGS_HEADER)] [ShowAssetPreview] public Sprite itemIcon;
here is the Stacktrace:
NullReferenceException: Object reference not set to an instance of an object NaughtyAttributes.Editor.PropertyUtility.GetAttributes[ShowAssetPreviewAttribute] (UnityEditor.SerializedProperty property) (at Assets/Plugins/NaughtyAttributes/Scripts/Editor/Utility/PropertyUtility.cs:20) NaughtyAttributes.Editor.ShowAssetPreviewPropertyDrawer.DrawProperty (UnityEditor.SerializedProperty property) (at Assets/Plugins/NaughtyAttributes/Scripts/Editor/PropertyDrawers/ShowAssetPreviewPropertyDrawer.cs:20) NaughtyAttributes.Editor.InspectorEditor.DrawField (System.Reflection.FieldInfo field) (at Assets/Plugins/NaughtyAttributes/Scripts/Editor/Editors/InspectorEditor.cs:232) NaughtyAttributes.Editor.InspectorEditor.ValidateAndDrawField (System.Reflection.FieldInfo field) (at Assets/Plugins/NaughtyAttributes/Scripts/Editor/Editors/InspectorEditor.cs:190) NaughtyAttributes.Editor.InspectorEditor.ValidateAndDrawFields (IEnumerable`1 fields) (at Assets/Plugins/NaughtyAttributes/Scripts/Editor/Editors/InspectorEditor.cs:182) NaughtyAttributes.Editor.InspectorEditor.OnInspectorGUI () (at Assets/Plugins/NaughtyAttributes/Scripts/Editor/Editors/InspectorEditor.cs:124) UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1245) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Confirmed working! Good job mate.
Von Samsung-Tablet gesendet
-------- Ursprüngliche Nachricht -------- Von: Denis Rizov notifications@github.com Datum: 05.03.18 16:21 (GMT+01:00) An: dbrizov/NaughtyAttributes NaughtyAttributes@noreply.github.com Cc: darktalestudio norman.krueger@live.nl, Author author@noreply.github.com Betreff: Re: [dbrizov/NaughtyAttributes] Issue with ShowAssetPreview and SerializeField (#13)
Fixed it mate. When I was trying to get the field info via reflection the “private” fields weren’t accessible, because child classes can’t see them. Now I am getting only the declared fields of each class. I am doing this for all classes in the hierarchy while there is a parent class.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/dbrizov/NaughtyAttributes/issues/13#issuecomment-370453147, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ahw_nIEpzd8X1fMhmIgw5YsTfS54DH4nks5tbVfugaJpZM4R8KSm.
Fixed it mate. When I was trying to get the field info via reflection the “private” fields weren’t accessible, because child classes can’t see them. Now I am getting only the declared fields of each class. I am doing this for all classes in the hierarchy while there is a parent class.