Search code examples
c#unity-game-enginehololensmrtk

The type or namespace "Toolkit" does not exist in the namespace "Microsoft.MixedReality" with MRTK3


So I made a new Unity Project with the MXTK3 and Unity Version 2021.3.6f1 (LTS). My goal is to track an QR Code, show a small Window with Data (What URL does the CR Code Contain) and then a Button to open the Link in the Endge Browser with the HoloLens 2. Sadly I can't access CameraCache as I can't import the Toolkit because I got the following error:

Assets\Scripts\SpatialGraphNodeTracker.cs(2,30): error CS0234: The type or namespace name 'Toolkit' does not exist in the namespace 'Microsoft.MixedReality' (are you missing an assembly reference?)

I used the Tool to install following Packages from MRTK3:

  • MRTK Core Definitions
  • MRTK Graphic Tools
  • MRTK Input
  • MRTK Spatial Manipulation
  • MRTK Standard Assets
  • MRTK UX Components
  • MRTK UX Core Scripts

Beside that just The one XR Thing from Plattform. Any ideas what I can try?

VS shows the packages but not the imports


Solution

  • Got my solution from here: https://forum.unity.com/threads/unity-removes-project-reference-to-packages.1324617/#post-8374734

    If your code is in a .asmdef assembly, you have to locate the asmdef file for QRCodeSample and set the appropriate references in its Inspector view. Seeing as you get a VS project for Microsoft.MixedReality.Toolkit.Core, that assembly seems to be a .asmdef assembly itself (as opposed to precompiled), which means you should add that asmdef in the "Assembly Definition References" section of your .asmdef Inspector.

    If your code is just going to Assembly-CSharp or similar, then you're going to want to either modify the package itself to mark the asmdef for Microsoft.MixedReality.Toolkit.Core "Auto Referenced" or add a .asmdef for your code and set up the required asmdef references yourself.

    Thanks again to cyriaca