Skip to content

Integration with Unity - static vs instance callbacks #75

@VISTALL

Description

@VISTALL

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions