Exemplo n.º 1
0
    void SendHeadRotationToMotionServer()
    {
        if (Application.platform != RuntimePlatform.Android)
        {
            return;
        }

        double now = (DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds;

        if (timeLastExecution < now)
        {
            timeLastExecution = now + Config.config.sendHeadRotationInterval;

            // get camera rotation
            Vector3 currentHeadPosition = Camera.main.gameObject.transform.rotation.eulerAngles;

            if (HeadPositionHasChanged(currentHeadPosition))
            {
                lastHeadPosition = currentHeadPosition;

                string json = JsonUtility.ToJson(HeadRotation.fromVector3(currentHeadPosition));

                AndroidJavaClass plugin = new AndroidJavaClass(Config.pluginClassString);
                plugin.CallStatic("sendMessageToMotionWebSocket", json);
            }
        }
    }
Exemplo n.º 2
0
    private void OnApplicationPause(bool pause)
    {
        if (Application.platform == RuntimePlatform.Android && pause == true)
        {
            AndroidJavaClass plugin = new AndroidJavaClass(Config.pluginClassString);

            string json = JsonUtility.ToJson(HeadRotation.fromVector3(new Vector3(0, 0, 0)));
            plugin.CallStatic("sendMessageToMotionWebSocket", json);
        }
    }
Exemplo n.º 3
0
    void SendHeadRotationToMotionServerMock()
    {
        double now = (DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds;

        if (timeLastExecution < now)
        {
            timeLastExecution = now + Config.config.sendHeadRotationInterval;

            // get camera rotation
            Vector3 currentHeadPosition = Camera.main.gameObject.transform.rotation.eulerAngles;

            if (HeadPositionHasChanged(currentHeadPosition))
            {
                lastHeadPosition = currentHeadPosition;
                string json = JsonUtility.ToJson(HeadRotation.fromVector3(currentHeadPosition));
                Debug.Log(json);
            }
            Debug.Log("Position is the same");
        }
    }