WP plugin problem

Hello guys! I followed this guide https://docs.unity3d.com/Documentation/Manual/wp8-plugins-guide-csharp.html to create a plugin for my unity game! In this tutorial this man uses a propriety, but I need to implement methods! Anyone knows if is possible?

Yes, it is possible - follow the guide exactly, but instead of making a property, make a public static method and just call that in your code.

Thanks Kyle! It works with almost all my methods…the problems now are with the async methods! Do you know I manage them?

They don’t even need to be static, non static ones should work as well.

As for asynchronous methods - uhh that will be ugly. You’ll have to block them with .Wait(), if that’s available, and if it’s not (like in Networking case), using C++ would be much easier. You can reference WinRT Components from the plugin directory, and that should work fine.

Thank you for this info Tautvydas!

For what concerns the asynchronus methods I need to use a “public async void” method and in it I’m calling something like “await blablabla”…shouldn’t it behave like .Wait() you suggested?

What I have used is a two-step process for async methods.

In your function, declare a public void function

public void DoSomething()

Then declare a private async void function (ONLY in the Windows Phone 8 plugin, doesn’t need to exist in the .NET 3.5 plugin)

private async void DoSomethingAsync()

Finally, in the DoSomething function, it should start the async function call.

If you need to return a value after the async function, consider using a callback function or an event to listen to.

-Kyle