🌑

脑洞杂货铺

UnityAR识别-VuforiaNote

VuforaiNote

对象识别:官方文档阅读顺序捷径

增加切换识别的功能按钮

  • 在Vuforia中加入切换识别的功能
    // 开启识别标签
    public bool recognitionTag;
    [HideInInspector]
    public bool currRecognitionState;
    
    private void Start()
    {
        recognitionTag = false;
        currRecognitionState = true;
    
        // 插入打开关闭识别功能
        VuforiaARController.Instance.RegisterTrackablesUpdatedCallback(OpenCloseRecognition);
    }
    void OpenCloseRecognition()
    {
        var objTracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
        if (recognitionTag && !currRecognitionState)
        {
            print("<color=red>objTracker" + objTracker.ToString() + "</color>: Start");
            if (objTracker != null)
            {
                objTracker.Start();
                currRecognitionState = true;
            }
        }
        if (!recognitionTag && currRecognitionState)
        {
            print("<color=red>objTracker" + objTracker.ToString() + "</color>: Stop");
            if (objTracker != null)
            {
                objTracker.Stop();
                currRecognitionState = false;
            }
        }
    }

, — 2021年2月1日