yasirkula / UnityAssetUsageDetector

Find usages of the selected asset(s) and/or Object(s) in your Unity project, i.e. list the objects that refer to them
MIT License
1.73k stars 118 forks source link

NullRef #23

Closed ssoher closed 4 years ago

ssoher commented 4 years ago

I receive a nullref with the below stack trace since the last Asset Store version. It only happens on some of the assets. Asset type makes no difference afaik, it happens on textures, scriptable object assets, scripts etc.

Stack contents: 
6: Portal (UnityEngine.Animation)
5: Portal (UnityEngine.GameObject)
4: AIFinalBoss (DisableGameobjectsOnDisable)
3: AIFinalBoss (UnityEngine.GameObject)
2: EnemySpawner (Defender3D.Scripts.Systems.EnemySpawner)
1: LevelManager (Defender3D.Scripts.Level.LevelManager)
0: LevelManager (UnityEngine.GameObject)

Searching references of: 
DashOnDamage (Defender3D.Scripts.AI.FinalBoss.DashOnDamage)

System.NullReferenceException: Object reference not set to an instance of an object
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchComponent (UnityEngine.Object unityObject) [0x000ef] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1082 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) [0x0013e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:981 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchGameObject (UnityEngine.Object unityObject) [0x0006e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1049 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) [0x00124] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:979 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchVariablesWithSerializedObject (AssetUsageDetectorNamespace.ReferenceNode referenceNode) [0x00065] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1437 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchComponent (UnityEngine.Object unityObject) [0x0028e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1123 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) [0x0013e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:981 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchGameObject (UnityEngine.Object unityObject) [0x0006e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1049 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) [0x00124] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:979 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchVariablesWithSerializedObject (AssetUsageDetectorNamespace.ReferenceNode referenceNode) [0x00065] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1437 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchComponent (UnityEngine.Object unityObject) [0x0028e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1123 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) [0x0013e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:981 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchVariablesWithSerializedObject (AssetUsageDetectorNamespace.ReferenceNode referenceNode) [0x00065] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1437 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchComponent (UnityEngine.Object unityObject) [0x0028e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1123 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) [0x0013e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:981 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchGameObject (UnityEngine.Object unityObject) [0x0006e] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:1049 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchObject (System.Object obj) [0x00124] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:979 
  at AssetUsageDetectorNamespace.AssetUsageDetector.BeginSearchObject (UnityEngine.Object obj) [0x00017] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:929 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchGameObjectRecursively (UnityEngine.GameObject go) [0x00001] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:914 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchGameObjectRecursively (UnityEngine.GameObject go) [0x00014] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:918 
  at AssetUsageDetectorNamespace.AssetUsageDetector.SearchScene (System.String scenePath, System.Collections.Generic.List`1[T] searchResult, System.Boolean lazySearch, UnityEditor.SceneManagement.SceneSetup[] initialSceneSetup) [0x000dd] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:880 
  at AssetUsageDetectorNamespace.AssetUsageDetector.Run (AssetUsageDetectorNamespace.AssetUsageDetector+Parameters searchParameters) [0x00ef9] in E:\project\defender\src\Assets\AssetUsageDetector\Editor\AssetUsageDetector.cs:637 

UnityEngine.Debug:LogError(Object)
AssetUsageDetectorNamespace.AssetUsageDetector:Run(Parameters) (at Assets/AssetUsageDetector/Editor/AssetUsageDetector.cs:711)
AssetUsageDetectorNamespace.AssetUsageDetectorWindow:InitiateSearch() (at Assets/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:630)
AssetUsageDetectorNamespace.AssetUsageDetectorWindow:ShowAndSearchInternal(IEnumerable`1, Parameters) (at Assets/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:219)
AssetUsageDetectorNamespace.AssetUsageDetectorWindow:ShowAndSearch(IEnumerable`1) (at Assets/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:146)
AssetUsageDetectorNamespace.AssetUsageDetectorWindow:SearchSelectedAssetReferences(MenuCommand) (at Assets/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:132)
yasirkula commented 4 years ago

Here's the problematic line: https://github.com/yasirkula/UnityAssetUsageDetector/blob/98d1f43180e35da173582f3fb0260ce871019547/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs#L1082

The following condition must return false for this component in order to reach the above line: https://github.com/yasirkula/UnityAssetUsageDetector/blob/98d1f43180e35da173582f3fb0260ce871019547/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs#L937-L938

So, somehow the Animation component is not null and is not Equal to null but it throws a NullReferenceException when we attempt to iterate its animation clips. I don't know how this can happen. Can you check Portal object's Animation component and see if there is anything unusual with it (e.g. unassigned animation clips, missing component or component removed from prefab instance)?

To check if the issue is related to the latest version, please import the previous versions from here (1.7.8 and older versions) and see if the issue is resolved.

ssoher commented 4 years ago

I made a bunch of changes on the Portal object before I saw your reply, tried to search again and everything seems to be in working order now. Sadly, I now have no clue why that happened. Feel free to close this issue, I'll add a comment if I encounter the same problem at any point. Emeklerin için teşekkür ederim, çok faydasını görüyorum 🙋‍♂️

yasirkula commented 4 years ago

Alright, closing the issue then 🙂