Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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

Discussion in 'Extensions & OnGUI' 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?