Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created June 19, 2024 11:39
Show Gist options
  • Save unitycoder/18f6d19cfa217586e2e9b0d89bd302ba to your computer and use it in GitHub Desktop.
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
// 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