Unity-Harry / Unity-AssetDependencyGraph

An Asset Dependency Graph for Unity
Other
354 stars 42 forks source link

Fix null reference exception when trying to explore object in a scene #3

Closed rfadeev closed 5 years ago

rfadeev commented 5 years ago

Summary

Check Selection.activeTransform to early return from ExplodeAsset if active transform is not null. For objects selected in project view active transform is null, for objects in the scene it's not (also for objects selected in prefab view it's not null).

How to reproduce exception

Open any scene and select object in the scene hierarchy. Click "Explore Asset" button and observe exception. This is caused by ExplodeAsset failed to load selected asset properly with assetPath being empty string and mainObject being null.

Unity-Harry commented 5 years ago

Heya, thanks so much for the contribution! I've gone ahead and fixed up that use case, we can actually use the result from AssetDatabase.GetAssetPath(obj) which will return an empty string when obj is an object in a scene. (b7a1105)