Search Unity

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:
    199
    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:
    199
    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:
    194
    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:
    194
    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:
    199
    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.