How to properly work with plateform dependend code in editor

Hi guys !

Actually I’m trying to build some udp socket for hololens, however to get them to work I need to use the Windows.Networking dependency which does not work under editor.
I can build and run them for hololens however it’s a hassle to debug since I have to wait 10 min to build so I can debug my code.

Don’t you guys have a workaround for an healthier development workflow ?

To anyone taking the time to read this , Thanks !

You could use platform dependent compilation to run only supported code in the editor.

#if UNITY_EDITOR
//unity editor workarround code
#elif  UNITY_WSA
//Hololense code / wsa
#endif

Thanks for the reply ,
The library Windows.Networking is not part of the WSA plateform , but a deeper subset (NETFX_CORE). If you try to import this lib even when Unity is in UWP plateform it’ll cause an error. You can only build it and launch it inside the headset.

Additionally I found this inside the documentation :

UNITY_WSA #define directive for Universal Windows Platform
. Additionally, NETFX_CORE is defined when compiling C# files against .NET Core and using .NET scripting backend