コード例 #1
0
 WebClientService_Gestures GetGestureService()
 {
     if (s_gestureClientService == null)
     {
         foreach (GameObject root in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects())
         {
             s_gestureClientService = root.GetComponentInChildren <WebClientService_Gestures>();
             if (s_gestureClientService != null)
             {
                 break;
             }
         }
     }
     return(s_gestureClientService);
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        m_isGestureActive = IsGestureActive();

        if (m_isGestureActive && Time.time - m_lastUpdateTime > 1.0f / UpdateFrequency)
        {
            SendUpdate();
        }

        WebClientService_Gestures service = GetGestureService();

        if (service == null)
        {
            Debug.Log(string.Format("Cannot activate the gesture '{0}'. No WebClientService_Gestures exists in the active scene.", GestureName));
            return;
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            service.ActivateGesture("turn_left", GetActivateParameters());
        }

        if (m_isGestureActive && !m_lastGestureActive)
        {
            service.ActivateGesture(GestureName, GetActivateParameters());
            m_lastUpdateTime = Time.time;
        }

        if (m_sendUpdate)
        {
            service.UpdateGesture(GestureName, GetUpdateParameters());
            m_lastUpdateTime = Time.time;
            m_sendUpdate     = false;
        }

        if (!m_isGestureActive && m_lastGestureActive)
        {
            service.DeactivateGesture(GestureName, GetDeactivateParameters());
        }

        m_lastGestureActive = m_isGestureActive;
    }