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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Resolved Reference Exception on Example Scenes after merging Mars with current Project

Discussion in 'Unity MARS' started by pat_unity618, Jan 31, 2021.

  1. pat_unity618

    pat_unity618

    Joined:
    Nov 22, 2018
    Posts:
    4
    Hey guys, this is great stuff, I'm looking to add Mars to my current ARFoundation project but it seems something has gone wrong with my current setup and I was hoping you could point me int he right direction.

    When playing any of the example scenes in a fresh project, it works fine. When trying in my current project, I get these errors.

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Unity.MARS.Data.IRequiresTraitsMethods.TryGetTraitValue[T] (Unity.MARS.Data.IRequiresTraits`1[T] obj, System.Int32 dataID, System.String traitName, T& value) (at Library/PackageCache/com.unity.mars@1.2.0/Interfaces/Traits/IRequiresTraits.cs:50)
    3. Unity.MARS.Data.Reasoning.GeoDuplicationReasoningAPI.ProcessScene () (at Library/PackageCache/com.unity.mars@1.2.0/Runtime/Scripts/Reasoning APIs/GeoDuplicationReasoningAPI.cs:31)
    4. Unity.MARS.Data.Reasoning.GeoDuplicationReasoningAPI.Setup () (at Library/PackageCache/com.unity.mars@1.2.0/Runtime/Scripts/Reasoning APIs/GeoDuplicationReasoningAPI.cs:24)
    5. Unity.MARS.Data.Reasoning.ReasoningModule.SetupReasoningAPIs () (at Library/PackageCache/com.unity.mars@1.2.0/Runtime/Scripts/Modules/ReasoningModule.cs:167)
    6. Unity.MARS.Data.Reasoning.ReasoningModule.Unity.XRTools.ModuleLoader.IModuleBehaviorCallbacks.OnBehaviorAwake () (at Library/PackageCache/com.unity.mars@1.2.0/Runtime/Scripts/Modules/ReasoningModule.cs:266)
    7. Unity.XRTools.ModuleLoader.ModuleLoaderCore.OnBehaviorAwake () (at Library/PackageCache/com.unity.xrtools.module-loader@1.2.0/Runtime/Scripts/ModuleLoaderCore.cs:580)
    8. UnityEngine.Debug:LogException(Exception)
    9. Unity.XRTools.ModuleLoader.ModuleLoaderCore:OnBehaviorAwake() (at Library/PackageCache/com.unity.xrtools.module-loader@1.2.0/Runtime/Scripts/ModuleLoaderCore.cs:584)
    10. Unity.MARS.MARSSession:Awake() (at Library/PackageCache/com.unity.mars@1.2.0/Runtime/Scripts/MARSSession.cs:128)
    11.  
    Unity Version 2019.4.18f1
    ARFoundation Version: 4.1.3
    ARKit 4.1.3
    Mars: 1.2.0

    Thanks, looking forward to adding this to our project.
     
  2. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    153
    Interesting; on a hunch, do you use GPS location (Input.location) in your AR Foundation project?
     
  3. pat_unity618

    pat_unity618

    Joined:
    Nov 22, 2018
    Posts:
    4
    Nope! No location stuff.
     
  4. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    153
    Scratch that hunch then...
    If you are able to can you file a bug using the bug reporter tool in the Editor? That will help us track this down.
     
  5. mtschoen

    mtschoen

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    Another hunch: Can you try deleting the `Assets/MARS/Generated` folder? This will trigger MARS to re-run code generation, which could fix the issue you are seeing. This may result in compile errors, so I recommend that you back up your project first.
     
  6. nouse20

    nouse20

    Joined:
    Oct 6, 2017
    Posts:
    8
    I'm not seeing any folder named "Generated" inside the MARS folder. Hopefully this helps in some way. :)
     
  7. nouse20

    nouse20

    Joined:
    Oct 6, 2017
    Posts:
    8
    Done!
     
  8. mtschoen

    mtschoen

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    Can you please provide the ticket number or a link to the ticket? You should have gotten an e-mail after submission with this info.
     
  9. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    153
    Found the root of this: Another plugin in the project (ReorderableInspector) is stomping on a callback we rely on to trigger our code generation.
    This has been fixed in their github repository but they haven't made a release since then. You can either grab the latest version of their code or edit the one you have, changing Editor/ReorderableArrayInspector.cs:65 from
    Code (CSharp):
    1. EditorApplication.delayCall = () => { EditorApplication.delayCall = () => { FORCE_INIT = false; }; };
    to
    Code (CSharp):
    1. EditorApplication.delayCall += () => { EditorApplication.delayCall = () => { FORCE_INIT = false; }; };
     
  10. pat_unity618

    pat_unity618

    Joined:
    Nov 22, 2018
    Posts:
    4
    Awesome! Thank you!
     
    mtschoen likes this.