Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Resolved Management does not exist in UnityEngine.XR

Discussion in 'XR Interaction Toolkit and Input' started by IvanTheTankable, Jul 25, 2022.

  1. IvanTheTankable

    IvanTheTankable

    Joined:
    Apr 22, 2021
    Posts:
    15
    Hello,

    I am trying to implement

    using UnityEngine.XR.Management;

    in a script I am writing, but visual studio 2022 is telling me that

    The type or namespace name 'Management' does not exist in the namespace 'UnityEngine.XR' (are you missing an assembly reference?)

    The package has worked fine elsewhere in the project in other scripts, I don't know why it would give me this problem here.

    My project is using the packages
    XR Interaction Toolkit 2.0.2
    XR Plugin Management 4.0.7
    Oculus XR Plugin 1.10.0
    OpenXR Plugin 1.2.8
    Visual Studio editor 2.0.16
     
  2. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    255
    Hi @IvanTheTankable,
    Do you have an asmdef file in your project? You may need to create one. You can then reference the Unity XR Management assembly by clicking the add button (
    +
    ) in the Assembly Definition References for your Assembly Definition file (see image).
    upload_2022-7-25_16-26-14.png
    The Assembly name is actually Unity.XR.Management, although the namespace in code will be
    using UnityEngine.XR.Management;
    as you noted above.
     
  3. IvanTheTankable

    IvanTheTankable

    Joined:
    Apr 22, 2021
    Posts:
    15
    I have several that seem to come from other packages I'm using, like Oculus and Mirror. Adding an asmdef with reference to Unity.XR.Management produced hundreds of new errors that seemed to be it not playing well with the others.
     
  4. IvanTheTankable

    IvanTheTankable

    Joined:
    Apr 22, 2021
    Posts:
    15
    Do you have any other suggestions, or did I perhaps mess something up in my creation of an asmdef file?
     
  5. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    255
    Hey @IvanTheTankable,
    When you created your asmdef file, did you happen to add the Oculus and Mirror assembly references? It might be that some of the scripts you had previously created in your project were referencing those other assemblies 'automatically'. When creating the asmdef, the existing references were not auto-populated in the Assembly Reference area of the asmdef, so any code that was using those would throw compiler errors.

    Try adding the other references and see if that fixes the errors. If not, please let us know and we'll keep investigating with you.
     
  6. IvanTheTankable

    IvanTheTankable

    Joined:
    Apr 22, 2021
    Posts:
    15
    I've added about fifty references now and am getting the feeling that something is wrong, I am getting errors to the tune of

    Assets\Scripts\VR Scripts\EnableXRInput.cs(4,19): error CS0234: The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)

    Having to add this many items seems like something about this asmdef is off, presently it's setup is
    unsafe code: no
    auto referenced: yes
    no engine reference: no
    override references: yes
    root namespace: (blank)
    no constraints defined
    Asm def refs:
    the many I have put randing from cinemachine to oculus
    Platforms: any
    version defines: empty

    Adding more does seem to slowly clear errors, but I sense there may be a simpler way?
     
  7. IvanTheTankable

    IvanTheTankable

    Joined:
    Apr 22, 2021
    Posts:
    15
    Images:
     

    Attached Files:

  8. LoneSurvivor82_1

    LoneSurvivor82_1

    Joined:
    Jul 6, 2021
    Posts:
    9
  9. langokalla

    langokalla

    Joined:
    Aug 4, 2020
    Posts:
    22
    It may seem cumbersome, but this is the way to work with AssemblyDefinitions. Now just make sure you also add the UnityEngine.XR.Management also. That will get rid of your errors.

    AssemblyDefs. will reduce your compile times and make code dependencies much clearer. This is a powerful tool to learn and use https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html
     
    VRDave_Unity likes this.
  10. IvanTheTankable

    IvanTheTankable

    Joined:
    Apr 22, 2021
    Posts:
    15
    I've acquired a better understanding of asmdef now, thanks. For starters, my problem was that my asmdef was in my root asset folder, not the folder with the problem script, which caused a lot more problems than it had to. The problem now is that I can't find a reference for a namespace called FreeDraw that I believe was put there by a team who worked on the project before me; I can't find it in the vs solution. Don't suppose any of you have had that problem before? :confused:
     
  11. IvanTheTankable

    IvanTheTankable

    Joined:
    Apr 22, 2021
    Posts:
    15
    I ended up just shuffling some folders around and things worked out.
     
    langokalla and VRDave_Unity like this.
  12. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    255
    It looks like you were able to get things shuffled around and working. Let us know if we can be of anymore help.