yasirkula / UnityRuntimeInspector

Runtime Inspector and Hierarchy solution for Unity for debugging and runtime editing purposes
MIT License
1.68k stars 135 forks source link

Fixed ArgumentOutOfRangeException when selecting ignored transform in editor #38

Closed i-xt closed 3 years ago

i-xt commented 3 years ago

How to reproduce the issue:

  1. Add RuntimeHierarchy.prefab to a new scene
  2. Enable Sync Selection With Editor Hierarchy option
  3. In play mode, click any ignored item (or child of ignored item) in the Unity hierarchy, e.g. anything beneath RuntimeInspector/ScrollView/Viewport/Content

ArgumentOutOfRangeException is thrown in RuntimeHierarchy:250

This PR prevents ignored transforms and children of ignored transforms from being selected.

yasirkula commented 3 years ago

Thank you for the PR. I've found a better way to avoid this issue by simply adding the following code:

if( m_depth < 0 ) // This object is hidden from Hierarchy
    return null;

To the top of this function: https://github.com/yasirkula/UnityRuntimeInspector/blob/cf9a5112b3f6b78325ff0018c15813588dbaf011/Plugins/RuntimeInspector/Scripts/RuntimeHierarchy/HierarchyData.cs#L214

Would you like to change your PR according to this or should I make this change with my own commit?

i-xt commented 3 years ago

Ok, that's indeed way simpler. I'll update the PR. Just give me a few minutes.

i-xt commented 3 years ago

I've updated the PR as suggested and tested again on my machine. Works fine.

yasirkula commented 3 years ago

Awesome, thanks! 🎉