Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

WP plugin problem

Discussion in 'Windows' started by Lele, Oct 14, 2013.

  1. Lele

    Lele

    Joined:
    Sep 13, 2013
    Posts:
    7
  2. BFS-Kyle

    BFS-Kyle

    Joined:
    Jun 12, 2013
    Posts:
    885
    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.
     
  3. Lele

    Lele

    Joined:
    Sep 13, 2013
    Posts:
    7
    Thanks Kyle! It works with almost all my methods...the problems now are with the async methods! Do you know I manage them?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,735
    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.
     
  5. Lele

    Lele

    Joined:
    Sep 13, 2013
    Posts:
    7
    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?
     
  6. BFS-Kyle

    BFS-Kyle

    Joined:
    Jun 12, 2013
    Posts:
    885
    What I have used is a two-step process for async methods.

    In your function, declare a public void function

    Code (csharp):
    1. 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)

    Code (csharp):
    1. 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