Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Detecting OS?

Discussion in 'Scripting' started by ryanzec, Jun 1, 2009.

  1. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    Is there a way to detect the OS the game is running on through scripting?
     
  2. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
  3. tungnguyendev

    tungnguyendev

    Joined:
    Mar 26, 2014
    Posts:
    13
    Also you can use as below function:
    Code (CSharp):
    1. public static string GetOS()
    2. {
    3.             string os = "Unknow";
    4. #if UNITY_EDITOR_WIN
    5.             os = "WIN";
    6. #endif
    7. #if UNITY_IOS
    8.             os = "IPHONE";
    9. #endif
    10. #if UNITY_ANDROID
    11.             os = "ANDROID";
    12. #endif
    13. #if UNITY_WEBGL
    14.             os = "WEBGL";
    15. #endif
    16.             return os;
    17. }