yasirkula / UnityRuntimeInspector

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

Feature: Scene filter #41

Closed i-xt closed 3 years ago

i-xt commented 3 years ago

Added the ability to filter which scenes are exposed to the hierarchy.

yasirkula commented 3 years ago

When I set the value of Exposed Scenes, does it prevent Dont Destroy On Load scene from being exposed unless I add it manually to the list (it shouldn't for this change to be merged)?

i-xt commented 3 years ago

In the current implementation it does, but I guess it would make sense not to do so. From my perspective Dont Destroy On Load is a special case and should be solely controlled by m_exposeDontDestroyOnLoadScene. I could easily update the PR. All that would be necessary is to change this line

if( !ExposeUnityScenes || (exposedScenes != null && exposedScenes.Length > 0 && System.Array.IndexOf(exposedScenes, arg0.name) == -1) )

to this

if( !ExposeUnityScenes || (arg0.buildIndex >= 0 && exposedScenes != null && exposedScenes.Length > 0 && System.Array.IndexOf(exposedScenes, arg0.name) == -1) )

Dont Destroy On Load has a build index of -1, which Unity does not allow for user created scenes, so we would just exclude all "Unity reserved scenes". Alternatively we could of course compare the scenes name, but that wouln't be my preferred solution.

i-xt commented 3 years ago

Alright, I've updated the PR according to my proposed solution. If you prefer a different solution, just let me know.

i-xt commented 3 years ago

I've implemented the requested changes. Should be fine now.

yasirkula commented 3 years ago

Thanks for the changes. I'll merge this PR as soon as possible. Sorry for the delay.

i-xt commented 3 years ago

No worries. Thanks for accepting the PR.