This isn't a feature/bug issue but rather an issue for refactoring/cleaning the SDK. As we are using callbacks in many parts of the C# wrapper, it is getting quite messy, we have the following pattern in multiple parts:
private static Action SomeCallback = null;
[DllImport("__Internal")]
private static extern void InternalJSLIBFunction(Action callback)
// Callback Invoker
[MonoPInvokeCallback(typeof(Action))]
private static void CallBackInvoker()
{
SomeCallback?.Invoke();
}
// Exposed Function
public static void ExposedFunction(Action callback)
{
SomeCallback = callback;
InternalJSLIBFunction(CallBackInvoker);
}
And to use the function we usually do something like this:
PlayroomKit.ExposedFunction(() = > {
// Do Something when callback is invoked
})
or
PlayroomKit.ExposedFunction(callback);
void callback()
{
// Do Something when callback is invoked
}
What we can do is to make a custom class for handling callbacks this will simplify the current codebase and make it easier for future updates/fixes.
This isn't a feature/bug issue but rather an issue for refactoring/cleaning the SDK. As we are using callbacks in many parts of the C# wrapper, it is getting quite messy, we have the following pattern in multiple parts:
And to use the function we usually do something like this:
or
What we can do is to make a custom class for handling callbacks this will simplify the current codebase and make it easier for future updates/fixes.