mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 21:55:43 +03:00
Fix macOS Runtime Platform determination failing
This commit is contained in:
parent
438127288a
commit
834bb451a7
@ -23,7 +23,7 @@ public static void ForUnity( string platform )
|
||||
|
||||
if ( platform == "OSXEditor" || platform == "OSXPlayer" || platform == "OSXDashboardPlayer" )
|
||||
{
|
||||
ForcePlatform( OperatingSystem.Osx, IntPtr.Size == 4 ? Architecture.x86 : Architecture.x64 );
|
||||
ForcePlatform( OperatingSystem.macOS, IntPtr.Size == 4 ? Architecture.x86 : Architecture.x64 );
|
||||
}
|
||||
|
||||
if ( platform == "LinuxPlayer" || platform == "LinuxEditor" )
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facepunch.Steamworks
|
||||
@ -8,7 +9,7 @@ public enum OperatingSystem
|
||||
Unset,
|
||||
Windows,
|
||||
Linux,
|
||||
Osx,
|
||||
macOS,
|
||||
}
|
||||
|
||||
public enum Architecture
|
||||
@ -26,6 +27,24 @@ internal static partial class Platform
|
||||
private static Facepunch.Steamworks.OperatingSystem _os;
|
||||
private static Facepunch.Steamworks.Architecture _arch;
|
||||
|
||||
public static Facepunch.Steamworks.OperatingSystem RunningPlatform()
|
||||
{
|
||||
switch (Environment.OSVersion.Platform)
|
||||
{
|
||||
case PlatformID.Unix:
|
||||
// macOS sometimes reports to .NET as Unix. Fix is to check against macOS root folders
|
||||
if (Directory.Exists("/Applications") && Directory.Exists("/System") && Directory.Exists("/Users") && Directory.Exists("/Volumes"))
|
||||
return Facepunch.Steamworks.OperatingSystem.macOS;
|
||||
else
|
||||
return Facepunch.Steamworks.OperatingSystem.Linux;
|
||||
case PlatformID.MacOSX:
|
||||
return Facepunch.Steamworks.OperatingSystem.macOS;
|
||||
|
||||
default:
|
||||
return Facepunch.Steamworks.OperatingSystem.Windows;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Facepunch.Steamworks.OperatingSystem Os
|
||||
{
|
||||
get
|
||||
@ -38,17 +57,8 @@ internal static Facepunch.Steamworks.OperatingSystem Os
|
||||
_os = Facepunch.Steamworks.OperatingSystem.Windows;
|
||||
|
||||
#if !NET_CORE
|
||||
//
|
||||
// These checks aren't so accurate on older versions of mono
|
||||
//
|
||||
if ( Environment.OSVersion.Platform == PlatformID.MacOSX ) _os = Facepunch.Steamworks.OperatingSystem.Osx;
|
||||
if ( Environment.OSVersion.Platform == PlatformID.Unix ) _os = Facepunch.Steamworks.OperatingSystem.Linux;
|
||||
|
||||
//
|
||||
// Edging our bets
|
||||
//
|
||||
if ( Environment.OSVersion.VersionString.ToLower().Contains( "unix" ) ) _os = Facepunch.Steamworks.OperatingSystem.Linux;
|
||||
if ( Environment.OSVersion.VersionString.ToLower().Contains( "osx" ) ) _os = Facepunch.Steamworks.OperatingSystem.Osx;
|
||||
// Fixed Bet
|
||||
_os = RunningPlatform();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -92,7 +102,7 @@ internal static Facepunch.Steamworks.Architecture Arch
|
||||
public static bool IsWindows32 { get { return Arch == Facepunch.Steamworks.Architecture.x86 && IsWindows; } }
|
||||
public static bool IsLinux64 { get { return Arch == Facepunch.Steamworks.Architecture.x64 && Os == Facepunch.Steamworks.OperatingSystem.Linux; } }
|
||||
public static bool IsLinux32 { get { return Arch == Facepunch.Steamworks.Architecture.x86 && Os == Facepunch.Steamworks.OperatingSystem.Linux; } }
|
||||
public static bool IsOsx { get { return Os == Facepunch.Steamworks.OperatingSystem.Osx; } }
|
||||
public static bool IsOsx { get { return Os == Facepunch.Steamworks.OperatingSystem.macOS; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user