Can Unity save selections after closing Unity?

I like the save selection feature in Unity. However, I can't reload my selections after re-opening Unity. Is there a place where these saved selection live where I can retrieve my selections?

Thanks

As far as I know the “Save selection” in the editor consists of temporary variables that cannot be re-used after you shutdown Unity.

The only thing you can do is to use a custom editor script to save your selection, I’ll help you on your way…

Start code

using UnityEngine;

using UnityEditor;

public class SaveSelection : ScriptableWizard

{

[MenuItem("Selection/Save Selection")]

public static void SaveSelection()

{

    ScriptableWizard.DisplayWizard(
        "Save Selection",
        typeof(SaveSelection),
        "Make Selection");
}

void OnWizardCreate()
{
    foreach (GameObject go in Selection.gameObjects)
    {
        Debug.Log(go.name);
    }
}

}

End Code

This is the code from a script you should call SaveSelection.
Where I just log the name of the gameobjects, you should serialize the selection to a file.

Then you only need another script similar to this one to load the selection from the file, i.e. setting Selection to your deserialized data.

Hope I helped you on your way.

Edit

Selection is something you can access in an editorscript.
You have to put the “using UnityEditor” statement in order to use this.