unity arkit无法多次扫描识别

2018-03-20  本文已影响0人  maoege

unity开发arkit过程中有个bug,每次在ar场景中进入到其他场景然后回到有ar场景中的时候ar场景会变混乱,我初始化了ar场景里面的东西,但是之前扫描的平面还在,并且会到处跑动,经过多处排查,在Assets/Plugins/ios/UnityARkit/UnityARCamerManager.cs这个文件中有这样一段断码

void Start(){

m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR

Application.targetFrameRate = 60;

ARKitWorldTackingSessionConfiguration config = new ARKitWorldTackingSessionConfiguration();

config.planeDetection = UnityARPlaneDetection.Horizontal;

config.alignment = UnityARAlignment.UnityARAlignmentGravity;

config.getPointCloudData = true;

config.enableLightEstimation = true;

m_session.RunWithConfig(config);

if(m_camera == null){

m_camera = Camera.main;

}

#else

........

#endif

}

重点可以看到的是虽然每次初始化arkit的congfig,但是并没有将之前扫描的点移除掉,这样我改成

UnityARSessionRunOption runOptions =  UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

ARKitWorldTackingSessionConfiguration sessionConfig = new  ARKitWorldTackingSessionConfiguration(UnityARAlignment.UnityARAlignmentGravity,UnityARPlaneDetection.Horizontal);

UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig,runOptions);

进入其他的场景回来再扫描,之前的东西没有了,并且可以再次扫描一个平台

上一篇下一篇

猜你喜欢

热点阅读