Search Unity

How have an editor script survive scene activation

Discussion in 'Editor & General Support' started by Capn_Andy, Nov 26, 2015.

  1. Capn_Andy

    Capn_Andy

    Joined:
    Nov 20, 2013
    Posts:
    80
    Hey there,

    I'm writing an editor script that's intended to open several scenes and perform actions on them. That's great; I can cycle through all the scenes and do whatever I want... Except actually hit "play."

    If I set EditorApplication.isPlaying = true, my editor script will continue to run - but any delegates I've set (say, for EditorApplication.update or EditorApplication.playStateChanged) will be trashed and can't be reinstated. Any static vars I've set in the editor script are trashed and I can't continue operation of the script after a time.

    Is there a way to have static vars in an editor script saved? Is there a way to have delegates survive a change in play state?

    (Currently running 5.3.0f1)