Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

rfadeev
Copy link

@rfadeev rfadeev commented Aug 24, 2019

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
Copy link
Owner

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)

@rfadeev rfadeev deleted the fix-null-ref-for-scene-object branch August 25, 2019 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants