Using UWP Universal Windows Platform API in Unity

I’m currently using Unity 5.6 and 2017.2b. I’m trying create a project of face tracking that uses UWP API, for example, face analysis and video frames. I setup everything and compiled the project as Universal Windows Platform in Unity 2017.2b and compiled as Windows Store with Universal 10 SDK option, both with Unity c# Project option checked. Then I open the built project using Visual Studio 2017, and put in the namespace using Windows.Media; and Visuak Studio can find reference to it. However, Unity can’t recognize it and keeps giving me compiler error:

error CS0246: The type or namespace name `Windows' could not be found. Are you missing an assembly reference?

Does anyone know how I can add reference of UWP APIs to Unity? I have my building setting and player setting in Unity 5.6 included in the post just in case they have issues, but I did followed instructions on Unity guide.

I also realize that although the project built with Windows Store (universal 10) platform has the reference of UWP API, the project .sln in the root folder of the project doesn’t have the reference. I tried to use Nuget in Visual Studio 2017 to installl Microsoft.NETCore.UniversalWindowsPlatform package, it failed with confusing error:

Could not install package 'Microsoft.CSharp 4.0.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5,Profile=Unity Subset v3.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

99055-unity1.png
99056-unity2.png

Hey, were you able to solve this? I’m running into a similar issue.

If anyone runs into this: know that Unity Editor uses different api than Unity WSA/UWP despite the build setting being set to Unity UWP.

To use UWP api, simply put
#if !UNITY_EDITOR && UNITY_WSA around the needed API.