So my project requires me to use Mars/AR to ‘scan’ the environment to generate equivalent geometry.
I then need to switch to a non-AR mode to be able to visualize that geo.
one way I could do this is simply create a list of the geometry (all the transforms and their respective meshes etc, well actually for the moment theyll just be cubes) in a monob. thats set to dontdestroyonload, and then load up a non-mars scene and recreate the geometry via script using the list.
However I suspect there must be a way to just switch off the ‘ar-camera’ feed so we can render just a normal scene (I’d also need to switch off all the mars proxys etc as well)
Surely there must be a way to do this without loading a scene ?
Hi there!
I think I know what you’re trying to do, but I want to confirm one point. Are you interested in stopping just the scan, or do you want to also disable camera tracking?
You can start/stop individual plane finding and point cloud using their Functionality Injection interfaces. For example Class IUsesPlaneFindingMethods | MARS | 1.0.1
Here is a script that we use for some of our samples to control the session
using System;
using TMPro;
using Unity.XRTools.ModuleLoader;
using UnityEngine;
using UnityEngine.Events;
namespace Unity.MARS
{
public class SessionUI : MonoBehaviour, IUsesFunctionalityInjection
{
class Subscriber : IUsesSessionControl, IUsesPointCloud, IUsesPlaneFinding, IUsesMarkerTracking
{
IProvidesSessionControl IFunctionalitySubscriber<IProvidesSessionControl>.provider { get; set; }
IProvidesPointCloud IFunctionalitySubscriber<IProvidesPointCloud>.provider { get; set; }
IProvidesPlaneFinding IFunctionalitySubscriber<IProvidesPlaneFinding>.provider { get; set; }
IProvidesMarkerTracking IFunctionalitySubscriber<IProvidesMarkerTracking>.provider { get; set; }
}
[Serializable]
class PauseEvent : UnityEvent<bool> { }
const string k_PauseText = "Pause";
const string k_ResumeText = "Resume";
#pragma warning disable 649
[SerializeField]
TextMeshProUGUI m_Text;
#pragma warning restore 649
readonly Subscriber m_Subscriber = new Subscriber();
IProvidesFunctionalityInjection IFunctionalitySubscriber<IProvidesFunctionalityInjection>.provider { get; set; }
void Start()
{
m_Text.text = MARSCore.instance.paused ? k_ResumeText : k_PauseText;
this.InjectFunctionalitySingle(m_Subscriber);
}
public void TogglePaused()
{
var paused = MARSCore.instance.paused;
if (paused)
{
m_Text.text = k_PauseText;
paused = false;
}
else
{
m_Text.text = k_ResumeText;
paused = true;
}
MARSCore.instance.paused = paused;
if (paused)
{
if (m_Subscriber.HasProvider<IProvidesPointCloud>())
m_Subscriber.StopDetectingPoints();
if (m_Subscriber.HasProvider<IProvidesPlaneFinding>())
m_Subscriber.StopDetectingPlanes();
if (m_Subscriber.HasProvider<IProvidesMarkerTracking>())
m_Subscriber.StopTrackingMarkers();
}
else
{
if (m_Subscriber.HasProvider<IProvidesPointCloud>())
m_Subscriber.StartDetectingPoints();
if (m_Subscriber.HasProvider<IProvidesPlaneFinding>())
m_Subscriber.StartDetectingPlanes();
if (m_Subscriber.HasProvider<IProvidesMarkerTracking>())
m_Subscriber.StartTrackingMarkers();
}
}
public void TriggerSessionReset()
{
if (m_Subscriber.HasProvider<IProvidesSessionControl>())
m_Subscriber.ResetSession();
}
}
}
If you also want to take control of the camera, I think you were on the right track. Just disable the AR camera and let it keep tracking, while you enable another camera to fly around the scene. If you really want to use our camera, you should be able to just disable the MARSCamera
component and take control of it, but you might run into trouble this way.
I hope this helps! Let me know if you have any more questions, or if I’m not understanding what you’re trying to do here.
Good luck!
1 Like