- Home /
Using .NET 4.6 features not supported by Unity WSA Build
Hi,
We are facing an issue trying to use .NET 4.6.1 System.Numerics.Vectors in a HoloLens app. An UWP API we are calling is returning a System.Numerics.Vectors Vector2 and Vector3.
To be clear, the code is only enabled for the UWP/WSA platform, so disabled in the Editor Mono runtime itself, using #if NETFX_CORE Still it fails during Build for WSA UWP 10 HoloLens in Unity: "Reference rewriter: Error: method System.Numerics.Vector2 Windows.Media.Devices.Core.CameraIntrinsics::get_FocalLength()
doesn't exist in target framework "
I assume this is because the WinRT / UWP / WSA target in Unity does not use .Net 4.6.1 yet. We tried with Unity 5.5 and 5.6. The workaround for now was to comment out the code in the script for Unity build and then to uncomment in VS when it's actually build for the HL.
But that is not a great workflow at all, so what is the best way to enable that?
We also tried to use the System.Numerics.Vectors NuGet package PCL DLL in Assets\Plugins which works in Unity but then fails during actual build in VS due to duplicate references. No surprise.
Another idea would be to make an extra .Net DLL only with that code pieces using System.Numerics.Vectors and then to include that DLL in Assets\Plugins\WSA so Unity does not process the DLL further during its build. But that's not a great approach.
TIA
Answer by MarekKowalski · Jan 26, 2018 at 08:17 AM
I am facing the same issue right now, a year later. Have you managed to solve it somehow?
Thanks,
Marek
Answer by _raj9 · Jan 29, 2018 at 05:45 AM
Unity 2017 should work with .NET 4.6 fine.
I tried turning on .NET 4.6 support but it still gives me the same error, no clue where to go on with this. The weirdest part is, that while I get the error when the VS project builds, and Unity says the build failed, the project in fact works just fine. This behaviour is independent of whether I use .NET 4.6 or not.
You can always create a custom dll for WSA and tell unity editor not to process the dll during it's build. basically that's what I ended up doing. It made sense as I had a larger native plugin which this could be a part of.