diff --git a/Plugins/Steamworks.NET/InteropHelp.cs b/Plugins/Steamworks.NET/InteropHelp.cs index a920435f..ad51e447 100644 --- a/Plugins/Steamworks.NET/InteropHelp.cs +++ b/Plugins/Steamworks.NET/InteropHelp.cs @@ -11,6 +11,10 @@ #if !DISABLESTEAMWORKS +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN +#define DLLCHECK +#endif + using System.Runtime.InteropServices; using IntPtr = System.IntPtr; @@ -19,7 +23,7 @@ namespace Steamworks { public class InteropHelp { public static void TestIfPlatformSupported() { -#if !UNITY_EDITOR && !UNITY_STANDALONE && !STEAMWORKS_WIN && !STEAMWORKS_LIN_OSX +#if !UNITY_EDITOR && !UNITY_STANDALONE throw new System.InvalidOperationException("Steamworks functions can only be called on platforms that Steam is available on."); #endif } @@ -65,7 +69,7 @@ public static string PtrToStringUTF8(IntPtr nativeUtf8) { // This is for 'const char *' arguments which we need to ensure do not get GC'd while Steam is using them. // We can't use an ICustomMarshaler because Unity crashes when a string between 96 and 127 characters long is defined/initialized at the top of class scope... -#if UNITY_EDITOR || UNITY_STANDALONE || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX +#if UNITY_EDITOR || UNITY_STANDALONE public class UTF8StringHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid { public UTF8StringHandle(string str) : base(true) { @@ -189,7 +193,7 @@ public static implicit operator IntPtr(MMKVPMarshaller that) { } public class DllCheck { -#if DISABLED +#if DLLCHECK [DllImport("kernel32.dll")] public static extern IntPtr GetModuleHandle(string lpModuleName); @@ -201,13 +205,14 @@ public class DllCheck { /// This is an optional runtime check to ensure that the dlls are the correct version. Returns false only if the steam_api.dll is found and it's the wrong size or version number. /// public static bool Test() { -#if DISABLED - bool ret = CheckSteamAPIDLL(); -#endif +#if DLLCHECK + return CheckSteamAPIDLL(); +#else return true; +#endif } -#if DISABLED +#if DLLCHECK private static bool CheckSteamAPIDLL() { string fileName; int fileBytes; @@ -235,10 +240,11 @@ private static bool CheckSteamAPIDLL() { if (fInfo.Length != fileBytes) { return false; } - +#if !ENABLE_IL2CPP if (System.Diagnostics.FileVersionInfo.GetVersionInfo(file).FileVersion != Version.SteamAPIDLLVersion) { return false; } +#endif } return true; }