Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question How to we call functions if we're using #IF_ENABLE_WINMD_SUPPORT

Discussion in 'Windows' started by TayannaStudios, Nov 27, 2022.

  1. TayannaStudios

    TayannaStudios

    Joined:
    Oct 18, 2013
    Posts:
    38
    How do we call functions when those functions are wrapped in #IF_ENABLE_WINMD_SUPPORT tags? Those functions don't technically exist in Unity when we do this so it leads to build errors and all sorts of other issues.

    I'm developing UWP for id@xbox and am getting absolutely nowhere. I've got the correct winmd and dll files installed. The Intellisense lights up correctly in VS.

    I've been trying to port our existing Windows game to UWP now for over 4 months at 12-20 hours every day, and I'm slowly going insane.

    Is there something I'm missing here?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    First of all, the tag is "#if ENABLE_WINMD_SUPPORT", not "#IF_ENABLE_WINMD_SUPPORT". Secondly, if it lights up in intellisense in Visual Studio, it should not produce build errors when exporting UWP player.

    Can you show some screenshots of Visual Studio recognizing the APIs and the Unity log from when it fails the build?
     
  3. TayannaStudios

    TayannaStudios

    Joined:
    Oct 18, 2013
    Posts:
    38
    Sorry, ignore the type error.

    I've solved the issue with the failed builds BUT my question about calling functions hidden within #if ENABLE_WINMD_SUPPORT still stands because how do we call one of those functions from something like the On Click() part of a UI button, for example, when the function doesn't show in the list because it's within an #if ENABLE_WINMD_SUPPORT?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Instead of wrapping the whole function, wrap only its body in the #if check. For instance instead of:

    Code (csharp):
    1. #if ENABLE_WINMD_SUPPORT
    2. void DoSomething()
    3. {
    4.     ....
    5. }
    6. #endif
    Do this:

    Code (csharp):
    1. void DoSomething()
    2. {
    3. #if ENABLE_WINMD_SUPPORT
    4.     ....
    5. #endif
    6. }