Created
June 19, 2024 11:39
-
-
Save unitycoder/18f6d19cfa217586e2e9b0d89bd302ba to your computer and use it in GitHub Desktop.
How to know if a script is running inside Unity Editor when using Device Simulator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://forum.unity.com/threads/how-to-know-if-a-script-is-running-inside-unity-editor-when-using-device-simulator.921827/ | |
public static class RunMode { | |
public enum ApplicationRunMode { | |
Device, | |
Editor, | |
Simulator | |
} | |
public static ApplicationRunMode Current { | |
get { | |
#if UNITY_EDITOR | |
return UnityEngine.Device.Application.isEditor && !UnityEngine.Device.Application.isMobilePlatform ? ApplicationRunMode.Editor : ApplicationRunMode.Simulator; | |
#else | |
return ApplicationRunMode.Device; | |
#endif | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment