示例#1
0
    /// <summary>
    /// Unity Monobehavior function. Initialization of video and tracking will be auto-started in the
    /// Update() loop. User customized functionalities can be place here. [internal use]
    /// </summary>
    private void Update()
    {
        if (!signalInitTriggered)
        {
            InitAsync();
            signalInitTriggered = true;
        }


        // Do stuff, for example, control the behavior of tracking and preview by bluetooth keyboard
        if (Input.GetKeyDown(KeyCode.P))
        {
            if (videoManager.videoPreview)
            {
                videoManager.DisablePreview();
            }
            else
            {
                videoManager.EnablePreview();
            }
        }
        if (Input.GetKeyDown(KeyCode.V))
        {
            if (status == ARUWP.ARUWP_STATUS_RUNNING)
            {
                Pause();
            }
            else if (status == ARUWP.ARUWP_STATUS_CTRL_INITIALIZED)
            {
                Resume();
            }
        }


        ARUWPUtils.RenderTick();
        renderDeltaTime = ARUWPUtils.GetRenderDeltaTime();
        trackDeltaTime  = ARUWPUtils.GetTrackDeltaTime();

        if (renderFPS != null)
        {
            renderFPS.text = string.Format("Render: {0:0.0} ms ({1:0.} fps)", renderDeltaTime, 1000.0f / renderDeltaTime);
        }
        if (trackFPS != null)
        {
            trackFPS.text = string.Format("Track:   {0:0.0} ms ({1:0.} fps)", trackDeltaTime, 1000.0f / trackDeltaTime);
        }
        signalTrackingUpdated = false;
    }