• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by woaihoh · Apr 12, 2014 at 02:00 AM · editorassetscriptableobject

Is there a message to be listen to when editor enter play mode?

$$anonymous$$, Im trying to detect the event on editor window when unity editor enter play mode. I need t$$anonymous$$s because everytime you enter play mode, unity destroy all the scriptableobject that i created, and i want to save t$$anonymous$$s objects to asset then recover them. I try the OnDestroy() but t$$anonymous$$s 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. w$$anonymous$$ch is kind of lame.

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by joshpsawyer · Apr 12, 2014 at 02:56 AM

When the editor is playing

 EditorApplication.isPlaying

will evaluate as true. T$$anonymous$$s might also be useful: http://forum.unity3d.com/threads/155352-Serialization-Best-Practices-Megapost

Reference:

  • https://docs.unity3d.com/Documentation/ScriptReference/EditorApplication-isPlaying.html

Comment
Nefisto

People who like this

1 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image woaihoh · Apr 12, 2014 at 09:45 AM 0
Share

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?

avatar image joshpsawyer · Apr 12, 2014 at 01:29 PM 0
Share

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.

avatar image

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

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

Save ScriptableObject On Unity Application Quit? 1 Answer

Why doesn't my ScriptableObject save using a custom EditorWindow? 3 Answers

ScriptableObject Asset corrupted after reload of Unity 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges