Vuforia切换回识别场景后黑屏解决

使用Vuforia SDK开发时,如果从其他非识别场景切换回识别场景,可能会出现黑屏问题。

解决方法是在切换到其他场景时,先将当前场景的Tracker信息全部Stop。代码如下:

IEnumerator LoadScenes(string sceneName)
    {
        if (TrackerManager.Instance.GetTracker<MarkerTracker>() != null)
        {
            MarkerTracker marker = TrackerManager.Instance.GetTracker<MarkerTracker>();
            marker.Stop();
        }

        if (TrackerManager.Instance.GetTracker<TextTracker>() != null)
        {
            TextTracker textTracker = TrackerManager.Instance.GetTracker<TextTracker>();
            textTracker.Stop();
        }

        if (TrackerManager.Instance.GetTracker<ObjectTracker>() != null)
        {
            ObjectTracker objTracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
            objTracker.Stop();
        }
     
    //此处返回waitForSeconds,因为我是在OnGUI中启动协程,如果不用WaitForSeconds,就会识别两次模型
yield return new WaitForSeconds(0.5f); //WaitForEndOfFrame(); Application.LoadLevel(sceneName); }

 

你可能感兴趣的:(Vuforia切换回识别场景后黑屏解决)