Ejemplo n.º 1
0
    private void SetupServer()
    {
        // Create web socket
        Debug.Log("Connecting" + WSManager.GetComponent <WSManager>().websocketServer);
        string url = "ws://" + WSManager.GetComponent <WSManager>().websocketServer + ":" + websocketPort;

        Jetfire.Open2(url);
    }
Ejemplo n.º 2
0
    private void RecordGrabLoc()
    {
        if (ActiveHandGesture == "pinch")
        {
            if (Grab.Instance.IsGrabbing && !m_isRecorded)
            {
                m_isRecorded = true;
                GameObject grabbedObj = Grab.Instance.GetGrabbingObject().gameObject;
                //Vector3 grabPos = grabbedObj.transform.position;
                Vector3 grabPos = grabbedObj.GetComponent <Selectable>().GetSnappedPosition();

                Vector2    newPos     = FocusUtils.WorldToUISpace(m_canvas, grabPos);
                GameObject new_marker = Instantiate(prefab_marker, Vector3.zero, Quaternion.identity, m_canvas.transform);

                new_marker.GetComponent <RectTransform>().anchoredPosition = newPos;
                m_markers.Add(new_marker);
                new_marker.SetActive(m_isMarkerDisplayed);

                if (m_markers_screenPos.Count < m_markerQueueLimit)
                {
                    m_markers_screenPos.Enqueue(new KeyValuePair <Vector2, long>(FocusUtils.WorldToScreenSpace(grabPos), System.DateTimeOffset.Now.ToUnixTimeMilliseconds()));
                }
                else
                {
                    m_markers_screenPos.Dequeue();
                    m_markers_screenPos.Enqueue(new KeyValuePair <Vector2, long>(FocusUtils.WorldToScreenSpace(grabPos), System.DateTimeOffset.Now.ToUnixTimeMilliseconds()));
                }

                UpdateCylinderCenter();

                // transmit data
                if (Jetfire.IsConnected2())
                {
                    string message = "Object grabbed," + newPos + "," + FocusUtils.WorldToScreenSpace(grabPos) + "," + FocusUtils.AddTimeStamp();

                    Color objColor = grabbedObj.GetComponent <Renderer>().material.color;
                    //if (m_sDM.TargetObjIDs.Contains(grabbedObj.GetInstanceID()))
                    if (grabbedObj.GetComponent <Selectable>().IsTarget)
                    {
                        message += ", target obj";
                    }
                    else
                    {
                        message += ", normal obj";
                    }

                    Jetfire.SendMsg2(message);
                    Debug.Log("JETFIREE" + objColor);
                }
            }
        }

        if (!Grab.Instance.IsGrabbing)
        {
            m_isRecorded = false;
        }
    }
Ejemplo n.º 3
0
    private void updateWebSocketServerInfo()
    {
        // websocketServer = websocketInputField.text;
#if UNITY_IOS && !UNITY_EDITOR
        Jetfire.Close();
#else
        webSocket.Close();
#endif
        OnEnable();
    }
Ejemplo n.º 4
0
    /// <summary>
    /// This function is called when the object becomes enabled and active.
    /// </summary>
    public void OnEnable()
    {
        // Create web socket
        Debug.Log("Connecting" + websocketServer);
        string url = "ws://" + websocketServer + ":" + websocketPort;

        // webSocket = new WebSocketUnity(url, this);

        // Open the connection
        // webSocket.Open();
        Jetfire.Open(url);
        // Jetfire.SendMsg("Hello!");
    }
Ejemplo n.º 5
0
    /// <summary>
    /// This function is called when the object becomes enabled and active.
    /// </summary>
    public void OnEnable()
    {
        if (DummyDataReplay)
        {
            return;
        }
        // Create web socket
        Debug.Log("Connecting" + websocketServer);
        string url = "ws://" + websocketServer + ":" + websocketPort;

#if UNITY_IOS && !UNITY_EDITOR
        Jetfire.Open(url);
#else
        if (DummyDataReplay)
        {
            return;
        }
        webSocket = new WebSocketUnity(url, this);
        // Open the connection
        webSocket.Open();
#endif
    }
Ejemplo n.º 6
0
    //public static void UpdateLinePos(LineRenderer line, Collider other, GameObject ActivePalm)
    //{
    //    line.SetPosition(0, ActivePalm.transform.position);
    //    line.SetPosition(1, other.gameObject.transform.position);
    //}


    public static void ToggleTimeStamp(bool isStart)
    {
        if (Jetfire.IsConnected2())
        {
            string message = "";

            if (isStart)
            {
                message += "Time start,";
            }
            else
            {
                message += "Time end,";
            }

            message += AddTimeStamp();


            Jetfire.SendMsg2(message);
            //Debug.Log("JETFIRE start/end");
        }
    }
Ejemplo n.º 7
0
 private void updateWebSocketServerInfo()
 {
     // websocketServer = websocketInputField.text;
     Jetfire.Close();
     OnEnable();
 }