dbrizov / NaughtyAttributes

Attribute Extensions for Unity
MIT License
4.58k stars 465 forks source link

"Target object is null" error spam every time I interact with an inspector that has a Canvas #348

Open trzy opened 1 year ago

trzy commented 1 year ago

Certain objects seem to trigger this error:

The target object is null. Check for missing scripts.
UnityEngine.Debug:LogError (object)
NaughtyAttributes.Editor.ReflectionUtility/<GetAllFields>d__0:MoveNext () (at Library/PackageCache/com.dbrizov.naughtyattributes@c5140c7dc3/Scripts/Editor/Utility/ReflectionUtility.cs:16)
System.Linq.Enumerable:FirstOrDefault<System.Reflection.FieldInfo> (System.Collections.Generic.IEnumerable`1<System.Reflection.FieldInfo>)
NaughtyAttributes.Editor.ReflectionUtility:GetField (object,string) (at Library/PackageCache/com.dbrizov.naughtyattributes@c5140c7dc3/Scripts/Editor/Utility/ReflectionUtility.cs:91)
NaughtyAttributes.Editor.PropertyUtility:GetAttributes<NaughtyAttributes.INaughtyAttribute> (UnityEditor.SerializedProperty) (at Library/PackageCache/com.dbrizov.naughtyattributes@c5140c7dc3/Scripts/Editor/Utility/PropertyUtility.cs:20)
NaughtyAttributes.Editor.PropertyUtility:GetAttribute<NaughtyAttributes.INaughtyAttribute> (UnityEditor.SerializedProperty) (at Library/PackageCache/com.dbrizov.naughtyattributes@c5140c7dc3/Scripts/Editor/Utility/PropertyUtility.cs:14)
NaughtyAttributes.Editor.NaughtyInspector/<>c:<OnInspectorGUI>b__7_0 (UnityEditor.SerializedProperty) (at Library/PackageCache/com.dbrizov.naughtyattributes@c5140c7dc3/Scripts/Editor/NaughtyInspector.cs:40)
System.Linq.Enumerable:Any<UnityEditor.SerializedProperty> (System.Collections.Generic.IEnumerable`1<UnityEditor.SerializedProperty>,System.Func`2<UnityEditor.SerializedProperty, bool>)
NaughtyAttributes.Editor.NaughtyInspector:OnInspectorGUI () (at Library/PackageCache/com.dbrizov.naughtyattributes@c5140c7dc3/Scripts/Editor/NaughtyInspector.cs:40)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Has anyone else experienced this?

I'm using the Hairibar Ragdoll package, which brings in NaughtyAttributes as a dependency. Currently, I've created a new project from scratch and am not even explicitly using anything from any of these packages yet.

wappenull commented 1 year ago

I got this on mouse over to the "Missing Script" (dead) component. So fix or remove the dead component should do it. Or better, add null check to NaughtyAttributes code to prevent this annoying error, but you are on your own on this. ;) image

TylerTemp commented 9 months ago

Like wappenull said, but this may help you actually finding it: FindMissingScriptsRecursively

PalaNolho commented 6 months ago

I'm getting that same error too

UnityEngine.Debug:LogError (object)
NaughtyAttributes.Editor.ReflectionUtility/<GetAllFields>d__0:MoveNext () (at Assets/_Scripts/NaughtyAttributes/Scripts/Editor/Utility/ReflectionUtility.cs:15)
System.Linq.Enumerable:FirstOrDefault<System.Reflection.FieldInfo> (System.Collections.Generic.IEnumerable`1<System.Reflection.FieldInfo>)
NaughtyAttributes.Editor.ReflectionUtility:GetField (object,string) (at Assets/_Scripts/NaughtyAttributes/Scripts/Editor/Utility/ReflectionUtility.cs:82)
NaughtyAttributes.Editor.PropertyUtility:GetAttributes<NaughtyAttributes.INaughtyAttribute> (UnityEditor.SerializedProperty) (at Assets/_Scripts/NaughtyAttributes/Scripts/Editor/Utility/PropertyUtility.cs:20)
NaughtyAttributes.Editor.PropertyUtility:GetAttribute<NaughtyAttributes.INaughtyAttribute> (UnityEditor.SerializedProperty) (at Assets/_Scripts/NaughtyAttributes/Scripts/Editor/Utility/PropertyUtility.cs:14)
NaughtyAttributes.Editor.NaughtyInspector/<>c:<OnInspectorGUI>b__7_0 (UnityEditor.SerializedProperty) (at Assets/_Scripts/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs:40)
System.Linq.Enumerable:Any<UnityEditor.SerializedProperty> (System.Collections.Generic.IEnumerable`1<UnityEditor.SerializedProperty>,System.Func`2<UnityEditor.SerializedProperty, bool>)
NaughtyAttributes.Editor.NaughtyInspector:OnInspectorGUI () (at Assets/_Scripts/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs:40)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)