MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Improve UWP scripting workflow

Open gwendalbroudinpro opened this issue 8 years ago • 8 comments

Does this affect the legacy HoloToolkit (master) or the Mixed Reality Toolkit (mrtk_release)? HoloToolkit and Mixed Reality Toolkit

Hello,

On Unity 2018, .NET scripting back end for UWP is deprecated. We now have to use IL2CPP scripting back end.

Because of that, we don't have a way to have IntelliSense and other tooling for UWP C# code (inside UNITY_WSA compilation symbols), since the dll and the compilation symbols are not available in the unity project. Is there a way to generate some kind of "scripting only project" with the proper .sln/csproj/dll files in order to add UWP targeted code more easily ?

I don't have any experience with msbuild stuff but if you know how we could reproduce Unity's UWP C# project generation, I'll be glad to implement it =).

gwendalbroudinpro avatar Oct 05 '18 13:10 gwendalbroudinpro

You should be able to open the unity project's solution and get intellesense on Windows namepace symbols as long as you have il2cpp set.

There's no need to add an additional project.

As for debugging, unity is trying to get their managed debugger working so you can attach to a running app on a HoloLens or device to make that easier, but I think it's still some ways off.

StephenHodgson avatar Oct 05 '18 15:10 StephenHodgson

@gwendalbroudinpro My team has continued to use .NET with MRTK as the scripting backend even though its deprecated.

There is currently a bug open in mrtk_development that prevents MRTK compiling under .NET, but it is likely to get fixed today: https://github.com/Microsoft/MixedRealityToolkit-Unity/issues/2874

@davidkline-ms and I are committed to keeping MRTK working under .NET as long as it's included in Unity, despite it being deprecated.

Would using .NET fix all your issues? Do you have another dependency that requires IL2CPP?

Ecnassianer avatar Oct 05 '18 17:10 Ecnassianer

I don't think using .NET would fix anything and would likely make some things worse or more complicated.

Yes it's easier to debug the solution with it, but that's the only pro in a long list of cons.

As it stands you should be able to get intellesense and all the required UWP tooling you need in the Unity Generated Project Solution so long as you're using IL2CPP. You won't get this if you're using .NET

  1. Make sure you've switched to the Windows Universal Build in Unity's Build Window. image
  2. Make sure you're using the 4.x equivalent scripting runtime version. image
  3. Make sure your Unity Project solution is generating the *Player project in your solution explorer. image
  4. Switch to the player project using the dropdown in the class you're currently editing image
  5. Use the UNITY_WSA or WINDOWS_UWP symbol defines along with !UNITY_EDITOR image
  6. ??? Profit

Although, you'll still need to build and run the windows stuff outside of the editor, as long as you're not working with HoloLens specific stuff (for example you could just test by installing it locally and running in WMR) you should be okay.

Also, IL2CPP gives better stack traces in their logging, where as .NET only gives you a message and possibly where it came from.

StephenHodgson avatar Oct 05 '18 23:10 StephenHodgson

Also, this question isn't really specific to MRTK, but a Unity UWP question in general. We're not Unity, nor affiliated with Unity in any way. It's up to them how they want to continue support for UWP specific tooling and such. I think if you want to make that suggestion, I'd post over on the Unity Forums.

That being said. I too miss .NET, but after seeing what the IL2CPP features enable, it's pretty easy to see why they chose to go down that path.

StephenHodgson avatar Oct 05 '18 23:10 StephenHodgson

@StephenHodgson would you mind linking an explanation of what the *.Player projects are, where you know from that these are necessary? I couldn't find anything about them.

Alexees avatar Oct 08 '18 08:10 Alexees

@StephenHodgson I've never saw this *.player csproj file either. I will post a message on Unity's forum then, thanks for your help ! @Alexees if I find anything, I will let you know. @Ecnassianer Thanks for your help but as @StephenHodgson said there are a lot of compatibility issues solved by using IL2CPP scripting backend, I just hope compilation time will be reduced by the Incremental Compilator because for now it is awfully long (15 min on core I7-7500 with 16GO RAM)

gwendalbroudinpro avatar Oct 08 '18 09:10 gwendalbroudinpro

Okay @Alexees I found how to generate the Player csproj file.

  1. Install VS 2017 with unity tools
  2. Set VS 2017 as your external script editor, instructions
  3. Close Unity
  4. Delete all .sln and .csproj files and Library and obj folder in your Unity project
  5. Reopen unity and click on open C# project in assets view, it will generate all sln and csproj files

I'm using unity 2018.1.9f2 by the way

gwendalbroudinpro avatar Oct 08 '18 10:10 gwendalbroudinpro

@Alexees i know from just from poking around and decompiling my amsdef generated assemblies.

There's not a whole lot on it. But they're essentially what ends up in the final app build.

StephenHodgson avatar Oct 08 '18 14:10 StephenHodgson