Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

How to get back an IntPtr in c++ for WP8 plugin?

Discussion in 'Windows' started by TribePlay, Oct 7, 2013.

  1. TribePlay

    TribePlay

    Joined:
    Sep 24, 2013
    Posts:
    1
    Hi there.

    I'm new on the forum and also in dev for winphone platform.
    I'm right now stuck because I don't know how to pass an IntPtr type from my c# code to my c++ code. It's actually much easier for android or iOS plugin since we can get back the data as a void*.
    However in a Windows Phone Runtime Component project it's not possible. So I use WinRT type.

    Here are my code samples:

    In C#:
    Code (csharp):
    1.  
    2. public delegate void WP8EnableTextureDrawing(System.IntPtr texture);
    3. private WP8EnableTextureDrawing wp8EnableTextureDrawing;
    4. public void SetWP8TextureDrawingFunc(WP8EnableTextureDrawing func)
    5. {
    6.     wp8EnableTextureDrawing = func;
    7. }
    8.  
    9.  
    10. //...
    11.  
    12. wp8EnableTextureDrawing(targetTexture.GetNativeTexturePtr());
    13.  
    In the c++ header file I matches the delegate this way:
    Code (csharp):
    1.  
    2. static void enableTextureDrawing(Platform::Object ^texturePtr);
    3.  
    But the compiler throws this error ->
    No overload for 'WP8TextureDrawing.TextureDrawing.enableTextureDrawing(object)' matches delegate 'NativeTextureDrawer.WP8EnableTextureDrawing'

    I hope someone who has already get his hands in this would help me out.

    Thanks
     
    Last edited: Oct 7, 2013
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
    Well you could cast it to int, and pass it as integer.