- Home /
Is there a message to be listen to when editor enter play mode?
hi, Im trying to detect the event on editor window when unity editor enter play mode. I need this because everytime you enter play mode, unity destroy all the scriptableobject that i created, and i want to save this objects to asset then recover them. I try the OnDestroy() but this message only be received when i close the editor window. What I am doing now is save objects manually before enter the playmode and when the object reference == null, i reload them from asset. which is kind of lame.
Answer by joshpsawyer · Apr 12, 2014 at 02:56 AM
When the editor is playing
EditorApplication.isPlaying
will evaluate as true. This might also be useful: http://forum.unity3d.com/threads/155352-Serialization-Best-Practices-Megapost
Reference:
Hi, i read through the first article and fix the issue when entering the play mode using the way that article provide. but when i close the unity editor(not the editor window) the scritableObject still got destroyed and there is not event that i know of to listen to. will you be able to help me with it, plz?
Unfortunately I haven't done much with editor customization, you might need to create an asset file? http://buchhofer.com/2010/10/unity-toying-with-scriptable-objects/
It's probably worth asking this as its own question, to ensure that it gets the attention it requires.
Answer by rhys_vdw · Jan 11, 2021 at 04:37 AM
There is now EditorApplication.playModeStateChanged
event.
https://docs.unity3d.com/ScriptReference/EditorApplication-playModeStateChanged.html
Your answer
Follow this Question
Related Questions
Problem with ScriptableObject and Custom Editor 2 Answers
Save ScriptableObject On Unity Application Quit? 1 Answer
How can I find all instances of a Scriptable Object in the Project (Editor) 3 Answers
[Solved]Why doesn't my ScriptableObject based asset save using a custom inspector ? 1 Answer
Why doesn't my ScriptableObject save using a custom EditorWindow? 3 Answers