Closed i-xt closed 3 months ago
Thank you for the detailed Issue. I've been working hard on other plugins for a long while (hopefully not for long now) so I couldn't take a look at most other Issues (including this). Will see what can be done about it. It won't be trivial because objects can appear in pseudo-scenes as well and they can also be filtered in RuntimeHierarchy.
What is the field/property that lets the hierarchy know which one is the last selected by clicking it in the hierarchy?
public List<HierarchyField> GetDrawers(Transform transform) =>
drawers.FindAll(val => val.Data.BoundTransform == transform);
public void TreatAsLastSelected(HierarchyField drawer)
{
lastClickTime = Time.realtimeSinceStartup;
lastClickedDrawer = drawer;
}
I tried adding this on RuntimeHierarchy.cs and then call it like this
var items = hierarchy.GetDrawers(list[list.Count - 1]);
if (items.Count > 0)
hierarchy.TreatAsLastSelected(items[items.Count - 1]);
but it seems like I got the wrong lastClickedDrawer? Still has the same behavior as the issue....
However, the hierarchy uses a recycled list view, meaning that only the visible Transforms' HierarchyFields are generated.
Here's how I had resolved this issue on another project. Note that line numbers may not match exactly:
Description of the bug
When a Transform is selected without clicking it's field in the hierarchy (either by calling
RuntimeHierarchy.Select()
or by enablingRuntimeHierarchy.syncSelectionWithEditorHierarchy
and clicking the GameObject in Unity's hierarchy)RuntimeHierarchy.multiSelectionPivotTransform
andRuntimeHierarchy.multiSelectionPivotSceneData
are not set. As a result, the wrong items are selected when range selecting afterwards, without clicking another item in the hierarchy first.Reproduction steps
The easiest way to reproduce this is to use the syncSelectionWithEditorHierarchy option.
RuntimeHierarchy.syncSelectionWithEditorHierarchy
andRuntimeHierarchy.m_allowMultiSelection
to trueResult: The items between the one that was selected in step 3 and the one that was selected in step 5 get selected. Expected result: The items between the one that was selected in step 4 and the one that was selected in step 5 get selected.
Platform specs