From b7a1105b8aca96a67de5a49ae711fc2a25c3a3a6 Mon Sep 17 00:00:00 2001 From: Harry Rose Date: Sat, 24 Aug 2019 18:04:13 +0100 Subject: [PATCH] Handle user selecting an object from a scene (https://github.com/Unity-Harry/Unity-AssetDependencyGraph/pull/3) --- AssetDependencyGraph/Editor/AssetDependencyGraph.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AssetDependencyGraph/Editor/AssetDependencyGraph.cs b/AssetDependencyGraph/Editor/AssetDependencyGraph.cs index d87f5cf..c1892d4 100644 --- a/AssetDependencyGraph/Editor/AssetDependencyGraph.cs +++ b/AssetDependencyGraph/Editor/AssetDependencyGraph.cs @@ -105,11 +105,12 @@ public void OnDisable() private void ExplodeAsset() { Object obj = Selection.activeObject; - if (!obj) - return; - string assetPath = AssetDatabase.GetAssetPath(obj); + // assetPath will be empty is obj is null or isn't an asset (a scene object) + if (obj == null || string.IsNullOrEmpty(assetPath)) + return; + Group groupNode = new Group {title = obj.name}; Object mainObject = AssetDatabase.LoadMainAssetAtPath(assetPath);