Search Unity

Question Issue with pausing and unpausing MARS.

Discussion in 'Unity MARS' started by gjarnos, Jan 12, 2022.

  1. gjarnos

    gjarnos

    Joined:
    Jan 23, 2021
    Posts:
    3
    Hi,

    I'm working on doing a simple test in order to accomplish two things: 1. Turn off/on an overlayed image/model using ARKit Face Tracking in iOS and 2. at the same time the image/model is off I want the camera indicator light to also be off. This will imply to the user that tracking is off.

    I used a script from elsewhere in the forum provided by @mtschoen in order to pause MARS which is below. I also have a script which includes two buttons for the UI for which one pauses MARS and model.SetActive(false) and then the other button unpauses MARS and model.SetActive(true). The model in this case has a proxy on it. The pause script seems to cause an issue for me upon unpause. The app starts fine and tracking works correctly but after pausing, then unpausing the issue occurs. What is the correct process for shutting off the camera (and camera green light indicator in iOS) and removing an object from the user's view? Seemingly, MARS cannot unpause after pausing the first time. Once I unpause the object is untrackable and just floats in space not moving and every time I unpause after that I get the same result. While running in iOS I get a null reference error from MARS and I've provided the stack trace in this post - the error occurs as soon as I unpause. I have also tried commenting out the .SetActive() function for the model and I receive the same results from MARS pausing/unpausing. I've included pictures of the setup of my components as well. Let me know if something is amiss. Thank you.

    EDIT START: I have solved the MARS null reference error stated above which is great but the issue with the model floating in space and not tracking the face anymore after unpause still persists. I fixed the null reference in MARS by removing the Face Prefab object on the AR FaceManager component of AR Session Origin.

    In order to isolate my issue with unpausing further I have attempted to use a sort of default MARS setup in the hierarchy removing all references to AR Sessions. This is what it looks like now. Any suggestions to fix pausing?





    EDIT END





    Code (CSharp):
    1.     public void Button1Pressed()
    2.     {
    3.         session.TogglePaused();
    4.  
    5.         defaultFaceMask.SetActive(true);
    6.     }
    7.  
    8.     public void Button2Pressed()
    9.     {
    10.         session.TogglePaused();
    11.  
    12.         defaultFaceMask.SetActive(false);
    13.     }




    Code (CSharp):
    1. using System;
    2. using Unity.MARS.Providers;
    3. using Unity.MARS.Settings;
    4. using Unity.XRTools.ModuleLoader;
    5. using UnityEngine;
    6.  
    7. namespace Unity.MARS
    8. {
    9.     public class SessionUI : MonoBehaviour, IUsesFunctionalityInjection, IUsesSessionControl
    10.     {
    11.         IProvidesFunctionalityInjection IFunctionalitySubscriber<IProvidesFunctionalityInjection>.provider { get; set; }
    12.         IProvidesSessionControl IFunctionalitySubscriber<IProvidesSessionControl>.provider { get; set; }
    13.  
    14.         void Awake()
    15.         {
    16.             // Only necessary if this script isn't already in the scene when you press Play
    17.             //this.EnsureFunctionalityInjected();
    18.         }
    19.  
    20.         public void TogglePaused()
    21.         {
    22.             var marsCore = MARSCore.instance;
    23.             var wasPaused = marsCore.paused;
    24.             marsCore.paused = !wasPaused;
    25.             if (wasPaused)
    26.             {
    27.                 this.ResumeSession();
    28.                 Debug.Log("MARS RESUME");
    29.             }
    30.             else
    31.             {
    32.                 this.PauseSession();
    33.                 Debug.Log("MARS PAUSE");
    34.             }
    35.         }
    36.     }
    37. }

    Stack trace:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object.
    2.   at Unity.MARS.Providers.IUsesCameraOffsetMethods.ApplyOffsetToPose (Unity.MARS.Providers.IUsesCameraOffset obj, UnityEngine.Pose pose) [0x00000] in <00000000000000000000000000000000>:0
    3.   at Unity.MARS.Landmarks.FaceLandmarksAction.UpdateFaceLandmark (Unity.MARS.Landmarks.ILandmarkController landmark, Unity.MARS.Data.MRFaceLandmark landmarkType) [0x00000] in <00000000000000000000000000000000>:0
    4.   at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
    5.   at Unity.MARS.Landmarks.LandmarkController.UpdateLandmark () [0x00000] in <00000000000000000000000000000000>:0
    6.   at Unity.MARS.Landmarks.LandmarkController.SourceDataChanged (Unity.MARS.Landmarks.ICalculateLandmarks dataSource) [0x00000] in <00000000000000000000000000000000>:0
    7.   at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
    8.   at Unity.MARS.Proxy.OnClientMatchAcquire (Unity.MARS.Query.QueryResult queryData) [0x00000] in <00000000000000000000000000000000>:0
    9.   at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
    10.   at Unity.MARS.Query.AcquireHandlingTransform.CallHandlers (System.Collections.Generic.List`1[T] indices, Unity.MARS.Query.QueryResult[] results, System.Action`1[Unity.MARS.Query.QueryResult][]& handlers) [0x00000] in <00000000000000000000000000000000>:0
    11.   at Unity.MARS.Query.DataTransform`2+ProcessDelegate[T1,T2].Invoke (System.Collections.Generic.List`1[T] indexes, T1 in1, T2& output) [0x00000] in <00000000000000000000000000000000>:0
    12.   at Unity.MARS.Query.DataTransform.Tick () [0x00000] in <00000000000000000000000000000000>:0
    13.   at Unity.MARS.Query.QueryStage`2[T1,T2].Tick () [0x00000] in <00000000000000000000000000000000>:0
    14.   at Unity.MARS.Query.StandaloneQueryPipeline.OnUpdate () [0x00000] in <00000000000000000000000000000000>:0
    15.   at Unity.MARS.Query.QueryPipelinesModule.Unity.MARS.IModuleMarsUpdate.OnMarsUpdate () [0x00000] in <00000000000000000000000000000000>:0
    16.   at Unity.MARS.Simulation.MarsTimeModule.InvokeMarsUpdate () [0x00000] in <00000000000000000000000000000000>:0
    17.   at Unity.MARS.Simulation.MarsTimeModule.Unity.XRTools.ModuleLoader.IModuleBehaviorCallbacks.OnBehaviorUpdate () [0x00000] in <00000000000000000000000000000000>:0
    18.   at Unity.XRTools.ModuleLoader.ModuleLoaderCore.OnBehaviorUpdate () [0x00000] in <00000000000000000000000000000000>:0
    19. Unity.XRTools.ModuleLoader.ModuleLoaderCore:OnBehaviorUpdate()
    20.  













     
    Last edited: Jan 13, 2022
  2. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    Are you able to also try this on an Android ARCore device?