Search Unity

SystemInfo.operatingSystem check for Linux/SteamOS?

Discussion in 'Linux' started by Teku-Studios, Sep 29, 2016.

  1. Teku-Studios

    Teku-Studios

    Joined:
    Sep 29, 2012
    Posts:
    257
    Hi there,

    If I make a SystemInfo.operatingSystem check in a Linux/SteamOS system, will it always return a similar message? Let me show you an example:

    Code (CSharp):
    1. if(SystemInfo.operatingSystem.Contains("Linux"))
    2. {
    3.     if(SystemInfo.operatingSystem.Contains("64bit"))
    4.         GameManager.currentOS = GameManager.MACHINEOS.LINUX64;
    5.     else
    6.         GameManager.currentOS = GameManager.MACHINEOS.LINUX32;
    7. }
    Depending on the OS architecture, I need to load specific assets for the game (some for 64, some for 32). This code check works like a charm for both Windows and OSX based systems, but I can't have every different Linux OS out there to test, so I don't know if SystemInfo.operatingSystem will always output a message containing the 'Linux' word (also, what about SteamOS?).

    Should I handle this differently?
     
  2. Tak

    Tak

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    Yes, the operating system for all Linux systems will be: "Linux KernelMajor.KernelMinor distribution bitness" , where Linux, KernelMajor, KernelMinor, and bitness are retrieved from uname(2), and distribution is obtained from lsb_release if available ("unknown" otherwise).
     
    Teku-Studios likes this.
  3. Teku-Studios

    Teku-Studios

    Joined:
    Sep 29, 2012
    Posts:
    257
    Nice, thanks a lot! So, even for SteamOS, right (I guess SteamOS will be the distribution info)?
     
  4. Tak

    Tak

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    Yes, it should be (or maybe it will even be Debian, not sure off the top of my head).
     
    Teku-Studios likes this.
  5. Teku-Studios

    Teku-Studios

    Joined:
    Sep 29, 2012
    Posts:
    257
    Okay then. Thanks a lot.