Search Unity

  1. Unity 2018.3 is now released.
    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. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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

    Freaking-Pingo

    Joined:
    Aug 1, 2012
    Posts:
    289
    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?