question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with ShowAssetPreview and SerializeField

See original GitHub issue

Hey 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:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
darktalestudiocommented, Mar 6, 2018

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.

0reactions
dbrizovcommented, Mar 5, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug - [SerializeField] not working right?
I have an older version of unity, but I do not think that this is the problem. here are the places I utilize...
Read more >
dbrizov/NaughtyAttributes: Attribute Extensions for Unity
Drawer Attributes. Provide special draw options to serialized fields. A field can have only one DrawerAttribute. If a field has more than one,...
Read more >
ShowNonSerializedField — NaughtyAttributes 2.1.4 ...
There is no such issue with static non-serialized fields because their values are updated at compile-time. It supports only certain types bool ,...
Read more >
SerializeField vs public, will this cause problems later?
Conclusion. For Unity's Serializer it makes no difference whether a field now is public or [SerializeField] private , in both cases it uses ......
Read more >
master · Game-Savvy / OpenUnityLibraries / OUAttributes
Can only select either assets in the project, or objects in the scene. This also forces the select tool to filter shown objects....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found