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 /
  • Help Room /
avatar image
0
Question by Jessespike · Jun 28, 2016 at 06:41 PM · editorfocusplay mode

Keep Editor playing while in background

Is there a way to keep the Editor running it's play mode while in the background? Currently as soon as I focus another window, the Editor will suspend itself until focus is returned.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by callen · Jun 28, 2016 at 06:53 PM

See: http://answers.unity3d.com/questions/9899/how-do-you-keep-your-game-running-even-when-you-sw.html

It's in Edit -> Project Settings -> Player

But... this comment from jashan seems important:

Some people aren't finding this in more recent versions of Unity. But it's still there: In Player settings, under the section "Resolution and Presentation", you find "Resolution" and below that, there's "Run In Background".

This is only available for Web players and standalones, though (you won't find it when you have the iOS, Android or Flash tab selected.

Comment
Add comment · Show 3 · 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 Jessespike · Jun 28, 2016 at 07:00 PM 0
Share

yea the platform is set to iOS. Pretty silly that an Editor behavior would be tied to the Player Build settings. I suppose I could switch to Standalone during testing then switch back to iOS when I need to make a build :/

avatar image Bunny83 Jessespike · Jun 28, 2016 at 08:57 PM 1
Share

An alternative is to set Application.runInBackground inside Start or Awake to "true". Of course an iOS or Android application doesn't have such a setting since an App can't run in the background, only services.

The "player settings" is not an "editor setting" but a setting of the actual Unity player.

avatar image Jessespike Bunny83 · Jun 29, 2016 at 08:02 PM 3
Share

Good tip! This works:

 void Awake () {
     if (Application.isEditor)
         Application.runInBackground = true;
 }
avatar image
3

Answer by Gwom · Jun 18, 2020 at 10:55 AM

If you want something for the editor, put the following in a script called RunEditorInBackground and put in a folder called Editor:

 using UnityEngine;
 using UnityEditor;
 
 [InitializeOnLoad]
 public class RunEditorInBackground  : EditorWindow
 {
     // This constructor is called on load because of Initialise on Load tag
     static RunEditorInBackground()
     {
         // Need to delay this as cant call EditorPrefs in static constructor
         EditorApplication.playModeStateChanged += Running;
     }
 
     private static void Running(PlayModeStateChange obj)
     {
         if(EditorApplication.isPlaying)
             Application.runInBackground = true;
     }
 }
Comment
Add comment · 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
0

Answer by JasonC_ · May 27, 2021 at 09:26 PM

Here; from the answers here I put a toggle for it in the editor menu; stick this in your Editor folder somewhere:

 using UnityEditor;
 using UnityEngine;
 
 [InitializeOnLoad]
 public class PlayInBackground : MonoBehaviour {
 
     const string ITEM = "Edit/Play In Background";
 
     static PlayInBackground () {
         EditorApplication.delayCall += InitMenu;
     }
 
     static void InitMenu () {
         Menu.SetChecked(ITEM, Application.runInBackground);
     }
 
     [MenuItem(ITEM, priority = 300)]
     public static void TogglePlayInBackground () {
         Menu.SetChecked(ITEM, !Menu.GetChecked(ITEM));
         Application.runInBackground = Menu.GetChecked(ITEM);
     }
 
 }

The menu item will probably be down towards the bottom of the Edit menu.

That's a setting that's saved with the project already so it'll persist.

IMPORTANT: This is the same setting as "Run in Background" in the Build Settings, so if that setting is important for your platform, make sure it's set back to the correct value before a build!!

There's some bugs here in that the check state won't change if you change the Build Setting, and sometimes vice versa, but, I mean... I'm certainly not going to fix them. Seems to work well enough.

Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

53 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Entering Play mode is suddenly extremely slow 2 Answers

Long launch time 1 Answer

Components can finally be rearranged with the mouse, but since when? 1 Answer

Large Unity project running slow in editor 0 Answers

Crash when reimporting custom assets 0 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