diff --git a/Facepunch.Steamworks/Utility/Helpers.cs b/Facepunch.Steamworks/Utility/Helpers.cs index 26917a3..91dfe5e 100644 --- a/Facepunch.Steamworks/Utility/Helpers.cs +++ b/Facepunch.Steamworks/Utility/Helpers.cs @@ -73,4 +73,10 @@ internal class MonoPInvokeCallbackAttribute : Attribute { public MonoPInvokeCallbackAttribute() { } } + + /// + /// Prevent unity from stripping shit we depend on + /// https://docs.unity3d.com/Manual/ManagedCodeStripping.html + /// + internal class PreserveAttribute : System.Attribute { } } diff --git a/Facepunch.Steamworks/Utility/SteamInterface.cs b/Facepunch.Steamworks/Utility/SteamInterface.cs index 2ead970..d9d10ba 100644 --- a/Facepunch.Steamworks/Utility/SteamInterface.cs +++ b/Facepunch.Steamworks/Utility/SteamInterface.cs @@ -31,7 +31,6 @@ public void Init() return; } - PreservationHack(); throw new System.Exception( "Trying to initialize Steam Interface but Steam not initialized" ); } @@ -110,15 +109,5 @@ internal virtual void Shutdown() } public abstract void InitInternals(); - - internal void PreservationHack() - { - // - // Stop Utf8StringToNative.GetInstance getting culled by stuff like Unity's - // asselmbly optimization stuff. Here we just call it so it can't not exist. - // - var i = Utf8StringToNative.GetInstance( "don't cull this function" ); - i.GetNativeDataSize(); - } } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Utility/Utf8String.cs b/Facepunch.Steamworks/Utility/Utf8String.cs index 062847d..ac73835 100644 --- a/Facepunch.Steamworks/Utility/Utf8String.cs +++ b/Facepunch.Steamworks/Utility/Utf8String.cs @@ -38,6 +38,7 @@ public IntPtr MarshalManagedToNative(object managedObj) public void CleanUpManagedData(object managedObj) => throw new System.NotImplementedException(); public int GetNativeDataSize() => -1; + [Preserve] public static ICustomMarshaler GetInstance(string cookie) => new Utf8StringToNative(); }