1. 程式人生 > >Unity+Vuforia 自動對焦功

Unity+Vuforia 自動對焦功

 該指令碼直接拖放到場景中一直處於啟用狀態物件上就可以了,當在移動端觸屏即可實現相機對焦:

        CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
    }

    // Update is called once per frame
    void Update()
    {
        //if (m_bIsFocus)
#if UNITY_EDITOR
        if(Input.GetMouseButtonUp(0))
#elif UNITY_ANDROID || UNITY_IPHONE

        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
#endif
        {
            CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
        }
    }
}