Trying PreserveAttribute instead

This commit is contained in:
Garry Newman 2019-08-08 11:00:34 +01:00
parent 1a02a9c363
commit 4f6e8bf8d1
3 changed files with 7 additions and 11 deletions

View File

@ -73,4 +73,10 @@ internal class MonoPInvokeCallbackAttribute : Attribute
{
public MonoPInvokeCallbackAttribute() { }
}
/// <summary>
/// Prevent unity from stripping shit we depend on
/// https://docs.unity3d.com/Manual/ManagedCodeStripping.html
/// </summary>
internal class PreserveAttribute : System.Attribute { }
}

View File

@ -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();
}
}
}

View File

@ -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();
}