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

Build Application with Mono C# Compiler

Discussion in 'VR' started by xweix, Sep 12, 2016.

  1. xweix

    xweix

    Joined:
    Sep 12, 2016
    Posts:
    11
    I am working on porting an existing Unity application to HoloLens. There was a massive amount of script compilation errors if I set the Target Platform to "Windows Store" and then build the application. Most of the errors came from the incompatible APIs between Mono and .NET Core. The errors are removed if I set "Compilation Overrides" to "None" which force the application to use the Mono C# compiler / library. (reference: https://docs.unity3d.com/Manual/windowsstore-faq.html)

    However, although the Build succeeds and generates the VS .sln under the output folder, it's still impossible to compile the solution in Visual Studio 2015. It seems VS2015 are still using .NET Core libraries when building the application, like the "Compilation Overrides" is not effective. (Microsoft.NETCore.UniversalWindowsPlatform and WinRTLegacy) is visible in the references of the generated projects)

    My questions are: Does HoloLens application have to use the .NET Core compiler? How to get the application running in Window Store environment if it relies on APIs which only available in Mono but not .NET Core?

    Thank you very much!
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    It's possible to use .NET 3.5 API set if you switch to IL2CPP scripting backend. You'll then have an identical API surface compared to other Unity platforms.

    Don't use compilation overrides to change APIs you can use. It only changes the compiler (as you said), but doesn't change the available API surface. It was meant to use if you needed to reference your C# scripts from UnityScript, as it is unable to reference scripts compiled by Microsoft C# compiler.
     
    xweix likes this.
  3. xweix

    xweix

    Joined:
    Sep 12, 2016
    Posts:
    11
    That would be absolutely awesome! Thank you!

    However, when I choose "IL2CPP" as the scripting backend, I get "Currently selected scripting backend(IL2CPP) is not installed" in the "Build Settings" dialog. And I could not find the option to install IL2CPP in the installation dialog of Unity 5.4.0f3-HTP, only the ".NET Scripting Backend" was there. Do you know how could I install the IL2CPP backend properly?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Looks like the installer posted on this board is borked (there's no IL2CPP option while there should be). Let me see if I can cook you a new IL2CPP scripting backend installer over night.
     
    xweix likes this.
  5. xweix

    xweix

    Joined:
    Sep 12, 2016
    Posts:
    11
    I would really appreciate that. Thank you so much :)
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    It finished faster than I had expected:

    https://oc.unity3d.com/index.php/s/BJq6tnDmh8XJFHt

    Let me know if it works... I think the installer should match the latest HTP build, but just in case test it with empty project to make sure the thing works :).
     
  7. xweix

    xweix

    Joined:
    Sep 12, 2016
    Posts:
    11
    The package works perfectly. I installed that upon the Unity HTP version and have used it to successfully generated a workable UWP application from an empty project with IL2CPP scripting backend.

    When applying the IL2CPP to my project I also got the project generated and built successfully. Currently, there are a few errors in execution. But those errors are mismatching asset bundles (those were targeting another platform), which shall not have any relationship to the scripting backend. I'm going to fix them.

    Thanks again for your quick help! :)
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    I'm glad it worked out for you :).
     
  9. nbaja1

    nbaja1

    Joined:
    Jun 15, 2017
    Posts:
    2
    @Tautvydas-Zilys ,

    Would there be any way you could post another installer but for the non-hololens version? I happen to be running 5.4.0f3, but the non-hololens version. I am running into a similar issue, where I cannot seem to find a way to install the IL2CPP backend. I tried installing the hololens version you linked above to my Unity. It compiles but I get an error on the windows phone:

    Invalid serialized file version. File: "C:/data/Programs/WindowsApps/mApp_0.0.4.0_arm__pcbna9mkpb3j0/Data/globalgamemanagers". Expected version: 5.4.0f3-HTP. Actual version: 5.4.0f3.

    Thank you
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    soojcho likes this.
  11. 265lutab

    265lutab

    Joined:
    Sep 15, 2014
    Posts:
    155
    I'm having similar problems in a project I'm working on.
    I made this post about it.
    https://forum.unity.com/threads/err...or-windows-mixed-reality.508795/#post-3321995

    When I try changing to IL2CPP I'm getting
    I have tried both with Scripting Runtime Version 3.5 and 4.6 with the API compatibility level set to 4.6 and I have Compilation Overrides set to Use Net Core Partially.
     
    Last edited: Dec 14, 2017
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Did you even read the error message? It tells you to build to an empty folder because the folder you selected is not empty.
     
  13. 265lutab

    265lutab

    Joined:
    Sep 15, 2014
    Posts:
    155
    I realized that after I posted. Sorry forgot to update this. Now I have it building in Unity and Visual Studio without errors, but when the project runs in Visual Studio I'm getting a black screen in the Windows MR headset and then it slows down before Visual Studio (or sometimes the whole system) crashes. I'm currently using 2017.2.0p2-MRTP.
    This is the log from I'm getting from Visual Studio.

    https://drive.google.com/file/d/1VUhGmH3S6frcDqiX009eCRLT2ZLlRioO/view?usp=sharing
     
  14. soojcho

    soojcho

    Joined:
    Dec 11, 2017
    Posts:
    6
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Are you using Unity Download Assistant? It should download matching versions automatically.
     
    soojcho likes this.