From aee78e5a590e9f70d2c0f217dcd5f5318f905d51 Mon Sep 17 00:00:00 2001 From: Diphome Date: Mon, 7 Sep 2026 20:18:28 +0200 Subject: [PATCH] GUI: fix "Go to scene hierarchy" doing nothing on non-scene assets The Asset List context item was shown for every single selection, but only assets that are part of a GameObject (Components, and the Mesh under a MeshFilter/SkinnedMeshRenderer) carry a TreeNode. On any other asset the item appeared yet clicking it silently did nothing. Only show the item when the selected asset actually has a scene node, and make the jump robust: switch to the Scene Hierarchy tab, select the node, expand its ancestors and scroll it into view (EnsureVisible), then focus the tree. Also read the selection from the virtual list's backing list instead of Items[]. Co-Authored-By: Clue Opus 4.8 --- UnityRiftGUI/UnityRiftGUIForm.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/UnityRiftGUI/UnityRiftGUIForm.cs b/UnityRiftGUI/UnityRiftGUIForm.cs index 9a2e4de..6dd5b85 100644 --- a/UnityRiftGUI/UnityRiftGUIForm.cs +++ b/UnityRiftGUI/UnityRiftGUIForm.cs @@ -2110,7 +2110,11 @@ private void assetListView_MouseClick(object sender, MouseEventArgs e) if (assetListView.SelectedIndices.Count == 1) { - goToSceneHierarchyToolStripMenuItem.Visible = true; + // Only offer "Go to scene hierarchy" for assets that actually have a scene + // node (Components and the Mesh under a MeshFilter/SkinnedMeshRenderer); + // otherwise the item was shown but clicking it did nothing. + var single = visibleAssets[assetListView.SelectedIndices[0]]; + goToSceneHierarchyToolStripMenuItem.Visible = single.TreeNode != null; showOriginalFileToolStripMenuItem.Visible = true; } if (assetListView.SelectedIndices.Count >= 1) @@ -2280,12 +2284,15 @@ private void ExportMergeObjects(bool animation) private void goToSceneHierarchyToolStripMenuItem_Click(object sender, EventArgs e) { - var selectAsset = (AssetItem)assetListView.Items[assetListView.SelectedIndices[0]]; - if (selectAsset.TreeNode != null) - { - sceneTreeView.SelectedNode = selectAsset.TreeNode; - tabControl1.SelectedTab = tabPage1; - } + if (assetListView.SelectedIndices.Count == 0) + return; + var selectAsset = visibleAssets[assetListView.SelectedIndices[0]]; + if (selectAsset.TreeNode == null) + return; + tabControl1.SelectedTab = tabPage1; // switch to the Scene Hierarchy tab first + sceneTreeView.SelectedNode = selectAsset.TreeNode; + selectAsset.TreeNode.EnsureVisible(); // expand ancestors and scroll into view + sceneTreeView.Focus(); } private void exportAllAssetsMenuItem_Click(object sender, EventArgs e)