Search Unity

Question Hololens 2 Project: UnityEngine.XR.ARSubsystems and ARFoundation do not exist in UnityEngine.XR

Discussion in 'AR' started by Horst_IGD, Aug 9, 2022.

  1. Horst_IGD

    Horst_IGD

    Joined:
    Jul 25, 2022
    Posts:
    7
    Hello alltogether,

    today I encountered an error I could not fix various attempts and research:

    In my Unity project for the Hololens 2, I get two errors:
    1)
    Severity Code Description Project File Line Suppression State
    Error CS0234 The type or namespace name 'ARSubsystems' does not exist in the namespace 'UnityEngine.XR' (are you missing an assembly reference?)

    2)
    Severity Code Description Project File Line Suppression State
    Error CS0234 The type or namespace name 'ARFoundation' does not exist in the namespace 'UnityEngine.XR' (are you missing an assembly reference?)

    I do not know why, but Unity/VS2022 keeps telling me there are no such packages ARSubsystems and ARFoundation within UnityEngine.XR...

    I am using Unity 2021.3.2f1, the packages: OpenXR Plugin 1.4.2, AR Foundation 4.2.3, AR Subsystems 4.2.3, ARCore XR Plugin and ARKit XR Plugin 4.2.3, XR Plugin Management 4.2.1, among some others.

    When I type "using UnityEngine.XR." Visual Studion (2022) only proposes "using UnityEngine.XR.WSA" and "using UnityEngine.XR.Provider".

    Has anyone any thoughts on this one? I would appreciate it.

    Thanks
    Robin
     
  2. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Is this error thrown in AR Foundation, or in a script in your project? If you have custom assembly definitions in your project, make sure that you reference the ARFoundation and ARSubsystems assemblies. (https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html, see "Referencing another assembly")

    You can also try deleting your Library folder to have Unity re-import packages.
     
  3. Horst_IGD

    Horst_IGD

    Joined:
    Jul 25, 2022
    Posts:
    7
    Thank you for the reply. The error occurs in my own script where I try using ARFoundation and ARSubsystems. I don't have custom assembly definitions.

    I tried deleting the library folder having Unity re-import all packages - sadly it did not help.

    I would appreciate other thoughts on it. Thank you.
     
  4. mikeyrafier98

    mikeyrafier98

    Joined:
    May 19, 2022
    Posts:
    37
    Does creating new project with freshly import all packages working without any dependency problem?

    If yes, could be there is a script update (automatically, or manually by package manager, idk), which makes the dependency goes wrong.
    If no, then might want to re-install the unity engine (not Editor, just engine, e.g., 2022.X.XXX), then re-install the ARFoundation for Hololens 2 from package manager.

    Hopefully can help.
     
  5. ankur-unity

    ankur-unity

    Unity Technologies

    Joined:
    Aug 12, 2021
    Posts:
    34
    Is it possible to share the
    manifest.json
    from your project?
     
  6. Horst_IGD

    Horst_IGD

    Joined:
    Jul 25, 2022
    Posts:
    7
    Thank you for the answers. For some reason which I cannot retrace, the mentioned errors disappeared after I used another project that worked with the packages and migrated my code of the current project to it... awkwardly weird.

    However, this created another error:
    The type or namespace name 'WindowsMREnvironment' does not exist in the namespace 'UnityEngine.XR.WindowsMR' (are you missing an assembly reference?)

    The manifest of the current project looks like this:

    {
    "dependencies": {
    "com.fhgigdvrar.simpleusermenu": "file:../simpleusermenu-master",
    "com.microsoft.mixedreality.input": "file:MixedReality/com.microsoft.mixedreality.input-0.9.2006.tgz",
    "com.microsoft.mixedreality.openxr": "file:MixedReality/com.microsoft.mixedreality.openxr-1.4.4.tgz",
    "com.microsoft.mixedreality.toolkit.extensions": "file:MixedReality/com.microsoft.mixedreality.toolkit.extensions-2.8.2.tgz",
    "com.microsoft.mixedreality.toolkit.foundation": "file:MixedReality/com.microsoft.mixedreality.toolkit.foundation-2.8.2.tgz",
    "com.microsoft.mixedreality.toolkit.standardassets": "file:MixedReality/com.microsoft.mixedreality.toolkit.standardassets-2.8.2.tgz",
    "com.microsoft.mixedreality.toolkit.tools": "file:MixedReality/com.microsoft.mixedreality.toolkit.tools-2.8.2.tgz",
    "com.microsoft.mrtk.graphicstools.unity": "file:MixedReality/com.microsoft.mrtk.graphicstools.unity-0.4.0.tgz",
    "com.unity.collab-proxy": "1.15.18",
    "com.unity.feature.development": "1.0.1",
    "com.unity.ide.rider": "3.0.13",
    "com.unity.ide.visualstudio": "2.0.14",
    "com.unity.ide.vscode": "1.2.5",
    "com.unity.test-framework": "1.1.31",
    "com.unity.textmeshpro": "3.0.6",
    "com.unity.timeline": "1.6.4",
    "com.unity.ugui": "1.0.0",
    "com.unity.visualscripting": "1.7.6",
    "com.unity.xr.arfoundation": "4.2.3",
    "com.unity.xr.arkit": "4.2.3",
    "com.unity.xr.openxr": "1.4.2",
    "org.khronos.unitygltf": "https://github.com/dschie/UnityGLTF.git?path=/UnityGLTF/Assets/UnityGLTF",
    "com.unity.modules.ai": "1.0.0",
    "com.unity.modules.androidjni": "1.0.0",
    "com.unity.modules.animation": "1.0.0",
    "com.unity.modules.assetbundle": "1.0.0",
    "com.unity.modules.audio": "1.0.0",
    "com.unity.modules.cloth": "1.0.0",
    "com.unity.modules.director": "1.0.0",
    "com.unity.modules.imageconversion": "1.0.0",
    "com.unity.modules.imgui": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0",
    "com.unity.modules.particlesystem": "1.0.0",
    "com.unity.modules.physics": "1.0.0",
    "com.unity.modules.physics2d": "1.0.0",
    "com.unity.modules.screencapture": "1.0.0",
    "com.unity.modules.terrain": "1.0.0",
    "com.unity.modules.terrainphysics": "1.0.0",
    "com.unity.modules.tilemap": "1.0.0",
    "com.unity.modules.ui": "1.0.0",
    "com.unity.modules.uielements": "1.0.0",
    "com.unity.modules.umbra": "1.0.0",
    "com.unity.modules.unityanalytics": "1.0.0",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    "com.unity.modules.unitywebrequestaudio": "1.0.0",
    "com.unity.modules.unitywebrequesttexture": "1.0.0",
    "com.unity.modules.unitywebrequestwww": "1.0.0",
    "com.unity.modules.vehicles": "1.0.0",
    "com.unity.modules.video": "1.0.0",
    "com.unity.modules.vr": "1.0.0",
    "com.unity.modules.wind": "1.0.0",
    "com.unity.modules.xr": "1.0.0"
    }
    }
     
  7. ankur-unity

    ankur-unity

    Unity Technologies

    Joined:
    Aug 12, 2021
    Posts:
    34
    Which editor version are you using?

    `UnityEngine.XR.WindowsMR.WindowsMREnvironment` is in `com.unity.xr.windowsmr` package. This package has been deprecated in Unity editor 2021 and later. In these editor versions, HoloLens is supported via Microsoft's Mixed Reality OpenXR Plugin. See https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/choosing-unity-version
     
    Phippey and andyb-unity like this.
  8. Horst_IGD

    Horst_IGD

    Joined:
    Jul 25, 2022
    Posts:
    7
    Currently, I am using Unity 2021.3.2f1.

    So I am not quite sure. What would you suggest?
     
  9. mikeyrafier98

    mikeyrafier98

    Joined:
    May 19, 2022
    Posts:
    37
    This is only my suggestion.
    Based on Mr. Ankur said, the Unity 2021 version has some deprecated library, which might be one of the cause of your problem.
    If it's possible, I think you can try cloning the project, use the latest Unity 2022 version, then let the Unity update the library from 2021 (previous project) to the newer one.
    If it still occur the problem, I might want to remake the project using the latest version, but I know it will be pain.

    The terms of remake, not creating all stuffs from scratch.
    It's create a fresh new project, then try to migrate scripts, assets, etc., one by one.

    Good luck!
     
  10. ankur-unity

    ankur-unity

    Unity Technologies

    Joined:
    Aug 12, 2021
    Posts:
    34
    andyb-unity likes this.
  11. holo-krzysztof

    holo-krzysztof

    Joined:
    Apr 5, 2017
    Posts:
    77
    It means some code in your project references the Windows MR package, which does not exist in 2021 LTS (only up to 2020).

    If it's your code, you can try rewriting that part to use the OpenXR package instead. If it's third party code, well...you could try downgrading to 2020 LTS if you don't need any features that are 2021-only.

    We're using 2020 LTS for a HoloLens 2 project right now and it works ok so far.