microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Compilation error when setting up Unity project #9774

Closed belugum closed 3 years ago

belugum commented 3 years ago

Overview

I'm trying to install the MR Toolkit on a new Unity project, with no success so far.

Expected behavior

An empty Unity project with the MR Toolkit properly installed. I would like to try an example scene.

Actual behavior

Compilation errors:

Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@02ad4b906f00-1619991284858\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(472,13): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@02ad4b906f00-1619991284858\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(475,36): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@02ad4b906f00-1619991284858\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(478,35): error CS7069: Reference to type 'Matrix4x4' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@02ad4b906f00-1619991284858\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(863,57): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@02ad4b906f00-1619991284858\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(863,57): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found

And several other similar errors. I tried adding "using System.Numerics" on that script, but I get an other error about an unimplemented interface member: Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@02ad4b906f00-1619991284858\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(48,9): error CS0535: 'WindowsSceneUnderstandingObserver' does not implement interface member 'IMixedRealitySceneUnderstandingObserver.TryFindCentermostPlacement(int, Vector2, out Vector3)'

Steps to reproduce

Follow the getting started tutorial on an empty Unity 2020.3 LTS project: https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/welcome-to-mr-feature-tool#system-requirements Features I selected (with the default versions): all of Mixed Reality Toolkit, Mixed Reality Scene Understanding (in Platform Support), all of Other Features. Then try to load the Unity project (in my case I'm invited to enter safe mode to check compilation errors).

Unity editor version

2020.3.6f1

Mixed Reality Toolkit release version

1.0.2104.0-Beta

Thanks for your help! Let me know if you need more information.

keveleigh commented 3 years ago

@MaxWang-MS Have you seen this?

MaxWang-MS commented 3 years ago

Hi @belugum, the reason you are seeing this is probably the new Unity project is targeting standalone build target and the Api compatibility level is set to .NET Standard 2.0. To solve this issue in Unity (no matter safe mode or not) go to Edit -> Project Settings -> Player -> Other Settings -> Api compatibility level and change it to .NET 4.x. Also after successfully importing everything remember to switch the build target to UWP as Scene Understanding only works for HoloLens 2.

MaxWang-MS commented 3 years ago

Fixed in 2.7 via #9776

RobinopdeBeek commented 2 years ago

Hi @MaxWang-MS , I am still getting these compilation errors when trying to import the Scene Understanding package into my existing project. In the Samples project importing it goes smoothly though.

Unity version: 2020.3.24 MRTK versions: 2.7.3 Scene Understanding version: 0.6.0 Build Platform: UWP

I tried switching to .Net 4.x, but this made no difference. There is probably a reason why it doesn't work with my project, but I don't know where to look. Any suggestions?

MaxWang-MS commented 2 years ago

Hi @RobinopdeBeek, could you please post the exact error messages you receive after the import? Also are you using any DLLs in your project? It may be helpful if you compare the player settings between the sample project and your existing project to see if there is any difference.

RobinopdeBeek commented 2 years ago

Thanks for responding @MaxWang-MS, below are the exact error messages:

Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(496,13): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(499,36): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(502,35): error CS7069: Reference to type 'Matrix4x4' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(924,57): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(924,78): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(960,62): error CS7069: Reference to type 'Matrix4x4' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(1495,51): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(1495,72): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(1510,51): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(1511,52): error CS7069: Reference to type 'Vector2' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(1517,65): error CS7069: Reference to type 'Matrix4x4' claims it is defined in 'System.Numerics', but it could not be found
Library\PackageCache\com.microsoft.mixedreality.toolkit.foundation@14981ccb13a7-1640190649996\Providers\Experimental\WindowsSceneUnderstanding\WindowsSceneUnderstandingObserver.cs(1559,13): error CS7069: Reference to type 'Vector3' claims it is defined in 'System.Numerics', but it could not be found

It's a company project that has accumulated lots of DLLs over the years. Do you need a list of all of them? Here are some that might provide some insight:

I have looked at the Project Settings and the most notable differences are:

MaxWang-MS commented 2 years ago

Hi @RobinopdeBeek, given the issue you are facing only repros in your company's project, I am afraid that I am limited in the ways I could help. But I do want to share my understanding of "type not found in System.Numerics" issues generally: there are different flavors of .NET and some flavors only implement a subset of features (e.g. System.Numeric.Vectors is not part of .NET Standard). So to resolve the issue you need to make sure the right flavor of .NET is used in your project. Also please ensure that there has been no changes made to the Unity installation folder by hand, as there are such changes may cause the issue you are experiencing. I would also consider asking the question on Unity's forum.

RobinopdeBeek commented 2 years ago

Thanks @MaxWang-MS for the explanation. I was already afraid it would be something project specific that you couldn't help with. For now I will just work around it, untill I have time to investigate further. If I find a solution I will let you know :)

laultman commented 2 years ago

I am having this issues with a completely clean install of Unity 2020.3.39f1 LTS and a completely clean install of MRTK 2.8.2 using the Mixed Reality Feature Tool v1.0.2209.0 Preview. In projects with .NET 2.0 Standard I often include System.Numerics.Vectors (4.5.0) when working with 3D applications. That is likely the problem here. I don't know how to add a missing .NET dll dependency.

MaxWang-MS commented 2 years ago

Hi @laultman, have you tried the following?

Hi @belugum, the reason you are seeing this is probably the new Unity project is targeting standalone build target and the Api compatibility level is set to .NET Standard 2.0. To solve this issue in Unity (no matter safe mode or not) go to Edit -> Project Settings -> Player -> Other Settings -> Api compatibility level and change it to .NET 4.x. Also after successfully importing everything remember to switch the build target to UWP as Scene Understanding only works for HoloLens 2.

laultman commented 2 years ago

We are a small company doing government contracting. We have tried multiple times over the past 3 years to use Unity and MRTK in projects. Again, the time-effort-cost is forcing us to abandon our Unity/MRTK effort. Unity, is too unpredictable to be used in a government setting except as a stand-alone solution delivery. MRTK's documentation apparently can't keep up with the pace of Unity change nor can MRTK be counted on to work regardless of the documentation suggestions. MRTK does not keep pace with .NET and the breaking changes in .NET ensuring that MRTK will surely have issues. The only reason we resorted to Unity now were two, one we hoped that MRTK had matured and become more stable, and two we needed very specific functionallity to test. After wasting multiple days we still cannot test the functionality because we can't get a running Unity/MRTK project to successfully load and run. We are using Unity 2020.3.39f1 as directed in the documentation and using the current download of Mixed Reality Feature Tools. We have cleared all cache of prior versions, uninstalled Unity and removed all references to it from the test computer. Installed the current version of Unity Hub and installed the 2020.3.39f1 version editor. Visual Studio is 2020 17.3.4 fully patched on a Windows 11 Enterprise version fully patched. My expectation is that systems should work on currently supported platforms. That is not too much to ask I would think. I do not have the time to troubleshoot your products.

laultman commented 2 years ago

@MaxWang-MS, No you are wrong, I followed the setup instructions specifically and know very well that HoloLens 2 requires UWP. I create a new project and the first thing I do is to switch to UWP before anything else. I did not switch to .NET 4.x because the instructions state in the Microsoft WLT that .NET 2.0 Standard is required. This bears out my point, MRTK is not stable or maybe at least it is trying to support too much of Unity's quirks. Either your instruction are wrong or the code does not work - either way I have no project.

laultman commented 2 years ago

I restored an older version of a working project and it at least builds and runs although it is now "head-locked" in HoloLens 2. This app was deployed about a year ago and works fine on another HL2 device.

keveleigh commented 2 years ago

The head lock is interesting. My best guess is that WLT may have switched you over to an XR SDK plugin and your local MRTK is only configured for legacy XR, but you'd know your local project best as far as how you configured it. Which is it?

There is info at https://learn.microsoft.com/windows/mixed-reality/mrtk-unity/mrtk2/configuration/getting-started-with-mrtk-and-xrsdk?view=mrtkunity-2022-05#configuring-mrtk-for-the-xr-sdk-pipeline around making sure your profiles are properly configured. The camera profile would be most important for potentially fixing head lock.

I'm going to unlock this conversation for you to reply, but please let's try to work together better this time 😊 we're all still learning and exploring this relatively new XR world together, and a bit of kindness and understanding goes a long way! We understand some of this can be confusing and frustrating, but we're here to help!

laultman commented 2 years ago

@keveleigh I admit that frustration causes a little acid to creep out occasionally, In the vein of helping, documentation should not make assumptions. If assumptions are made, then those should be clearly stated with linkage to the novice playground, like the Tutorial. Also there is so much documentation (page count) that a person attempting to solve a problem simply does not have the time to read every page and likely the capacity to mentally retain its content.

That said, and in defense of myself and any others who must use a tool, it is very costly in time and effort to use a company's product that is less than adequately documented. I have the same issue in my own company - write code or write docs. My solution is, put money in the project to hire documentation people. Customers want the software to work and they want to get their money's worth. The latter comes from being able to read, watch video, look at diagrams, or pictures to get value from the software.

If the goal is commercial (making money) then documentation is essential or people will simply discard the product. If the goal is personal enjoyment, then frustrations due to documentation eliminates that immediately.

About the head-locking, I never was able to figure out the actual problem, but got it to work. Instead I tossed 3 days of effort, deleted all the projects and Unity from my computer and started again from scratch. Those 3 days were on my clock not my company time; several days of getting up at 4am and an entire weekend. It was not for enjoyment I can assure you.

I am taking the time here to relay my sense of frustrations about software. This is not new to Microsoft or many other companies including mine. Documentation is a source of real issues for real people. My only reason for responding is to raise the issue of the necessity to document and to link. Want to make things better? Then spend some time getting AI to document, if it is too much trouble for people.

Kind regards

havokentity commented 1 year ago

Weird the changing to .NET 4.x fix worked for me!