Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with Unity - static vs instance callbacks #75

Open
VISTALL opened this issue Aug 4, 2020 · 1 comment
Open

Integration with Unity - static vs instance callbacks #75

VISTALL opened this issue Aug 4, 2020 · 1 comment

Comments

@VISTALL
Copy link

VISTALL commented Aug 4, 2020

Hello. As i said in (#73) i am working on integration BulletSharpPInvoke in Unity.

I'm already fixed all problems, and most of them - i wrote in prev issue.

And now - library works as is in Unity(desktop, mac). But for mobile platforms Unity use IL2CPP (https://docs.unity3d.com/Manual/IL2CPP.html) and library not work (at android for example)

There a simple problem - Unity can't convert code with instance callbacks. @Phong13 already fix that problem here https://github.com/Phong13/BulletSharpUnity3d and here https://github.com/Phong13/BulletSharpPInvoke

Here example

https://github.com/AndresTraks/BulletSharpPInvoke/blob/master/BulletSharp/LinearMath/MotionState.cs#L34

		void GetWorldTransformUnmanaged(out Matrix worldTrans)

this method must be static and it provide problem about accessing to this. Now need receive it from wrapper (need new field in C++ wrapper code). And do those changes to all callbacks

(AOT attribute required by IL2CPP)

		#if ENABLE_IL2CPP
		[AOT.MonoPInvokeCallbackAttribute(typeof(GetWorldTransformUnmanagedDelegate))]
		#endif
		static void GetWorldTransformUnmanaged(IntPtr thisPtr, out Matrix worldTrans)

(also those change https://github.com/Phong13/BulletSharpUnity3d/blob/master/Plugins/BulletUnity/BulletSharp/Native.cs)

Without those changes, it can not be integrated into Unity as is. It's a small changes, almost without any overhead.

What do you think ?

@AndresTraks
Copy link
Owner

Yes, that looks fine to me.
Not sure when I'll get to this, but I accept pull requests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants