Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
7
Question by Eric 1 · May 11, 2010 at 07:16 PM · editorplaymode

Programmatically Start Play Mode in the Editor

Is there a way to programatically start the play mode in the Unity editor in an editor script?

Comment
Add comment
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
14
Best Answer

Answer by cob · May 11, 2010 at 07:29 PM

To launch from a menu item you would

[MenuItem("Play/PlayMe")]
public static void BuildAssetBundles()
{
    EditorApplication.isPlaying = true;
    EditorApplication.NewScene();
    GameObject go = new GameObject("PlayMode");
    go.AddComponent<PlaySomeMonoBehaviour>().WhatToDo =
        PlaySomeMonoBehaviour.PlayMe;
}

In the PlaySomeMonoBehaviour class

public const string PlayMe = "PlayMe";

public class PlaySomeMonoBehaviour : MonoBehaviour {

public string WhatToDo = PlayMe;

void Start() { switch (WhatToDo) { case PlayMe: StartCoroutine((YetSomeOtherClass.DoSomething())); break; } }

YetSomeOtherClass is just another MonoBehaviour manipulating GameObjects.

Comment
Add comment · 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 Eric 1 · May 11, 2010 at 08:57 PM 3
Share

That is the special sauce. Thanks. It is interesting that you named your sample class BuildAssetBundles...since I am trying to load AssetBundles to verify they are correct, and I cannot seen to do that in edit mode. Thanks!

Just to clarify for anyone else, doing:

EditorApplication.isPlaying = true;

Starts the play mode. The other code is a way to launch a specific $$anonymous$$onoBehaviour in a new, clean Unity scene.

Thanks again.

avatar image cob · May 12, 2010 at 12:54 PM 0
Share

oh, sorry... BuildAssetBundles... I meant to rename it to something generic but missed it. :)

avatar image
0

Answer by karsnen · May 21, 2019 at 05:53 PM

Yes dropping it here for anyone for an alternative that is awesome. http://wiki.unity3d.com/index.php/SceneAutoLoader

Comment
Add comment · 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 awsapps · Feb 24 at 10:57 AM 0
Share

Link unavailable :S

avatar image Hellium awsapps · Feb 24 at 11:17 AM 1
Share

https://web.archive.org/web/20210808070311/http://wiki.unity3d.com/index.php/SceneAutoLoader

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Manually triggering a script from the editor (utility, macro etc.) 1 Answer

Editor script - any callback when target is first instantiated? 1 Answer

Why does unity editor crash when exiting play mode, if it has been playing for more than 15 seconds? 1 Answer

Monodevelop crash my PC 2 Answers

Any script to 'fix' normals/winding order? 3 Answers


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