Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

...TreeViewDataSource.GetExpandedIDs - Keeps incrementing between Editor and Play mode

Discussion in 'Immediate Mode GUI (IMGUI)' started by Freaking-Pingo, Oct 23, 2018.

  1. Freaking-Pingo


    Aug 1, 2012
    We are currently trying to implement an editor tool that helps us switching scenes when entering playmode and then return to the previous scene you had open before you entered playmode. For that, we wish to recreate the collapse state of the Hiearchy Editor Window. We try implement this using reflection and using the functionality found in the non-documented:
    Code (CSharp):
    1. int[] UnityEditor.IMGUI.Controls.TreeViewDataSource.GetExpandedIDs()
    The primary issue we are facing is that it appears the GetExpandedIDs() increments when entering/leaving playmode. This can however be resolved by closing and opening the Hiearchy EditorWindow. The amount that is incremented between entering/exiting playmode seems to correlate with how many additive scenes that are loaded in the scene. E.g. if there is only 1 scene, GetExpandedIds() keeps incrementing with 1. If there are 2 scenes, it seems like it increments with 2.

    Anyone have an idea why this keeps getting incremented?