Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Everything under #if WINDOWS_UWP greyed out in Visual Studio, even though Build Settings targets UWP

Discussion in 'Windows' started by ArnoBen, Aug 24, 2020.

  1. ArnoBen

    ArnoBen

    Joined:
    Apr 24, 2019
    Posts:
    13
    Greetings,

    I am developing for HoloLens and I need to use
    using Windows.Devices.Bluetooth
    so I added #if WINDOWS_UWP but all of my code under this directive is greyed out in Visual Studio, even though I switched to Universal Windows Platform in the Build Settings.
    #if UNITY_WSA_10_0 isn't greyed out but it doesn't include the Windows.Devices namespace.

    Unity 2019.4.6f1
    Visual Studio Community 2019 16.6.4

    Any help would be appreciated.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,645
    You should use "#if UNITY_WSA && ENABLE_WINMD_SUPPORT" define for using Windows Runtime namespaces.
     
  3. Din0m1te

    Din0m1te

    Joined:
    Sep 9, 2015
    Posts:
    33
    This does not work. #if WINDOWS_UWP used to work fine for me up until 2020.2. It's even in the docs still. Where is this change to "#if UNITY_WSA && ENABLE_WINMD_SUPPORT" documented?

    Removing "WINDOWS_UWP" just like that would be quite the breaking change.
     
  4. Din0m1te

    Din0m1te

    Joined:
    Sep 9, 2015
    Posts:
    33
    I can confirm now it still works. I hadn't checked the "Player Projects" checkbox in the external tools settings. When targeting UWP it's important to switch to the player project so WINDOWS_UWP can work.