How to stop plane detection using ARKit
Hi guys.
As I understand, plane detection is tough battery consumer process. Once I've got my plane and set the base object for the game, I wish to stop plane detection (or generating reference points). Does anybody knows a how to disable plane detection? and a how to enable it again?
Answer by unity_27hrishik · Feb 18, 2018 at 04:02 PM
@tonymunoz One way to do that that is by re-running the UnityARSessionNativeInterface's RunWithConfig() with the new parameters, that belong's in UnityARCameraManager script. If you haven't altered the script the two function should do the work :
public void planeDetectionON() { planeDetection = UnityARPlaneDetection.Horizontal; ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(); config.planeDetection = planeDetection; config.alignment = startAlignment; config.getPointCloudData = true; config.enableLightEstimation = true; m_session.RunWithConfig (config);
}
public void planeDetectionOFF()
{
planeDetection = UnityARPlaneDetection.None;
ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
config.planeDetection = planeDetection;
config.alignment = startAlignment;
config.getPointCloudData = false;
config.enableLightEstimation = false;
m_session.RunWithConfig (config);
}
by the way this worked for me. but i really don't know if this the real way to stop plane detection Hope it helps
Hi.
This solution effectively stop the plane and anchors generation. Thank you very much. The problem now is that the ones that were available an instant before running planeDetectionOff() are still on. I wish to remove them too. I've been trying adding this code to planeDetectionOff, but it's not working:
UnityARSessionRunOption options = new UnityARSessionRunOption();
options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
m_session.RunWithConfigAndOptions(config, options);
Lokking up the Arkit's Declearation the above code already exists RunWithConfig(). that is By Default the above code should run with those option but it's not running. Have no clue on how to stop it.
Answer by tonOnWu · Jan 23, 2018 at 02:09 AM
Hi guys. I have several days on this topic and nothing. I don't know a way to stop plane detection.
I have the same issue.
ref this question: https://forum.unity.com/threads/arkit-support-for-ios-via-unity-arkit-plugin.474385/page-18#post-3174684