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

Does UnitySetGraphicsDevice get called on the Windows Metro and WP8 Platforms?

Discussion in 'Windows' started by NewMetro, Sep 22, 2013.

  1. NewMetro

    NewMetro

    Joined:
    Sep 22, 2013
    Posts:
    4
    Hello,

    I'm working on porting my native PC plugin to Windows Metro and WP8. Does UnitySetGraphicsDevice get used on those platforms? It doesn't seem to be firing for me.

    Thanks!
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,745
    Hello,

    That function is used and should work. Could you describe how you're trying to use them?
     
  3. NewMetro

    NewMetro

    Joined:
    Sep 22, 2013
    Posts:
    4
    I took the MetroNativePluginsV1 sample and added a public int (test) to the top of Plugins.cpp. I then added the following:

    Code (csharp):
    1. int test = 0;
    2.  
    3. extern "C" int __declspec(dllexport) _stdcall GetInteger()
    4. {
    5.     if(test > 0)
    6.         return test;
    7.     else
    8.         return 15;
    9. }
    10.  
    11. // If exported by a plugin, this function will be called when graphics device is created, destroyed,
    12. // before it's being reset (i.e. resolution changed), after it's being reset, etc.
    13. extern "C" void __declspec(dllexport) UnitySetGraphicsDevice (void* device, int deviceType, int eventType)
    14. {
    15.     test = 20;
    16. }
    Test was never getting set to 20. I actually got UnitySetGraphicsDevice to trigger by adding the following line to the generated D3D11 C++ Application code (App.cpp -- void App::SetWindow(CoreWindow^ coreWindow))

    Code (csharp):
    1. m_AppCallbacks->LoadGfxNativePlugin("Plugins.dll");
    Is that the correct way to get UnitySetGraphicsDevice to trigger?

    Thanks!
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,772
    Yes, you have to call AppCallbacks::LoadGfxNativePlugin() in Windows Store Apps.
     
  5. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
  6. unsigned-user

    unsigned-user

    Joined:
    Oct 9, 2013
    Posts:
    2
    Hi,
    Since my question is close to the initial issue of this thread I ask away here.

    I want to do the exactly same thing that the poster of the thread but for windows phone build (not for a windows store apps).
    The problem is that I can't access the member functions of AppCallbacks class such as LoadGfxNativePlugin() or InitializeD3DWindow() in App.xaml.cs.

    Right now I'm really stuck and any help or suggestions will be appreciate.

    Thank you.