Skip to content

Commit

Permalink
Fixed drag&dropping multiple root Transforms in RuntimeHierarchy resu…
Browse files Browse the repository at this point in the history
…lting in incorrect Transform order (fixed #62)
  • Loading branch information
yasirkula committed Feb 23, 2025
1 parent b0980bb commit c2ce82e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Plugins/RuntimeInspector/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Runtime Inspector & Hierarchy (v1.7.2) =
= Runtime Inspector & Hierarchy (v1.7.3) =

Documentation: https://github.com/yasirkula/UnityRuntimeInspector
FAQ: https://github.com/yasirkula/UnityRuntimeInspector#faq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private bool DropTransformOnto( Transform droppedTransform, HierarchyData target

// If we are only changing the sibling index of the dropped Transform and not its parent, then make sure
// that the target sibling index won't be affected when the dropped Transform is shifted in the Hierarchy
if( droppedTransform.parent == newParent )
if( droppedTransform.parent == newParent || ( newScene != null && newScene.IndexOf( droppedTransform ) >= 0 ) )
{
if( newParent || ( newScene is HierarchyDataRootScene && ( (HierarchyDataRootScene) newScene ).Scene == droppedTransform.gameObject.scene ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ public void InsertChild( int index, Transform child )
}
else
{
index = Mathf.Clamp( index, 0, rootObjects.Count );
rootObjects.Insert( index, child );

// If the object was already in the list, remove the old copy from the list
for( int i = rootObjects.Count - 1; i >= 0; i-- )
{
if( i != index && rootObjects[i] == child )
{
rootObjects.RemoveAt( i );
break;
}
}
rootObjects.Remove( child ); // If the object was already in the list, remove the old copy from the list
rootObjects.Insert( Mathf.Clamp( index, 0, rootObjects.Count ), child );
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.yasirkula.runtimeinspector",
"displayName": "Runtime Inspector & Hierarchy",
"version": "1.7.2",
"version": "1.7.3",
"documentationUrl": "https://github.com/yasirkula/UnityRuntimeInspector",
"changelogUrl": "https://github.com/yasirkula/UnityRuntimeInspector/releases",
"licensesUrl": "https://github.com/yasirkula/UnityRuntimeInspector/blob/master/LICENSE.txt",
Expand Down

0 comments on commit c2ce82e

Please sign in to comment.