Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何重置或重新启动ARCore会话?_Java_Unity3d_Kotlin_Augmented Reality_Arcore - Fatal编程技术网

Java 如何重置或重新启动ARCore会话?

Java 如何重置或重新启动ARCore会话?,java,unity3d,kotlin,augmented-reality,arcore,Java,Unity3d,Kotlin,Augmented Reality,Arcore,我需要重置/重新启动ARCore会话。在ARKit中,我只需创建一个新的配置并执行RunWithConfigAndOptions方法,但在ARCore中找不到有关如何执行此操作的任何信息。以下是我在Unity中为ARKit使用的代码: ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(); config.planeDetection = UnityARPlaneDe

我需要重置/
重新启动
ARCore会话。在ARKit中,我只需创建一个新的配置并执行
RunWithConfigAndOptions
方法,但在ARCore中找不到有关如何执行此操作的任何信息。以下是我在Unity中为ARKit使用的代码:

ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
config.planeDetection = UnityARPlaneDetection.Horizontal;
config.alignment = UnityARAlignment.UnityARAlignmentGravity;
config.enableLightEstimation = true;  

UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, 
                                                                                    UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | 
                                                                                    UnityARSessionRunOption.ARSessionRunOptionResetTracking);
我在Unity工作,但我想任何信息都会有用

谢谢

尝试
立即销毁(会话)
销毁(会话)
。其中一个可能有效

ARCoreSession session = goARCoreDevice.GetComponent<ARCoreSession>();
ARCoreSessionConfig myConfig = session.SessionConfig;

DestroyImmediate(session);
// Destroy(session);

yield return null;

session = goARCoreDevice.AddComponent<ARCoreSession>();
session.SessionConfig = myConfig;
session.enabled = true;
ARCoreSession session=goARCoreDevice.GetComponent();
ARCoreSessionConfig myConfig=session.SessionConfig;
(会议);
//销毁(会议);
收益返回空;
session=goARCoreDevice.AddComponent();
session.SessionConfig=myConfig;
session.enabled=true;

希望这有帮助。

对于禁用ARCore会话

GameObject.Find ("ARCore Device").GetComponent<ARCoreSession> ().enabled = false;
//Resetting ARCoreSession
ARCoreSession session = GameObject.Find ("ARCore Device").GetComponent<ARCoreSession> ();
ARCoreSessionConfig myConfig = session.SessionConfig;
DestroyImmediate (session);
GameObject.Find(“ARCore设备”).GetComponent().enabled=false;
要重置ARCore会话

GameObject.Find ("ARCore Device").GetComponent<ARCoreSession> ().enabled = false;
//Resetting ARCoreSession
ARCoreSession session = GameObject.Find ("ARCore Device").GetComponent<ARCoreSession> ();
ARCoreSessionConfig myConfig = session.SessionConfig;
DestroyImmediate (session);
//重置ARCoreSession
ARCoreSession session=GameObject.Find(“ARCore设备”).GetComponent();
ARCoreSessionConfig myConfig=session.SessionConfig;
(会议);

谢谢。虽然销毁和重新创建组件而不是重置会话看起来很奇怪,但它可以工作,并且对我的游戏来说已经足够了。非常感谢您的帮助。对不起,我不明白如何使用这段代码。有针对Android的解决方案吗?嗯,好的,伙计,我将发布一个问题。如何针对Android执行此操作?