예제 #1
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, Screen.height - 250, 250, 250), ShowConfig ? Network_ON : Network_OFF, GUIStyle.none))
        {
            ShowConfig = !ShowConfig;
        }

        if (ShowConfig)
        {
            int newLine = 110;
            int width   = 1500;
            int height  = newLine;
            int bheight = height + ((int)0.5f) * height;


            int top  = 5;
            int left = 100;

            GUI.Label(new Rect(left, top, width, height), "Sending to: " + address + ":" + port, _normalText); top += newLine;
            GUI.Label(new Rect(left, top, width, height), "Gyro: " + Input.gyro.enabled, Input.gyro.enabled ? _normalText : _red); top += newLine;
            if (Input.gyro.enabled)
            {
                GUI.Label(new Rect(left, top, width, height), "Attitude: " + Input.gyro.attitude, _normalText);
            }
            top += newLine;
            if (Input.gyro.enabled)
            {
                GUI.Label(new Rect(left, top, width, height), "Rotation: " + gameObject.transform.rotation.ToString(), _normalText);
            }
            top += newLine;

            GUI.Label(new Rect(left, top, width, height), "x = " + gameObject.transform.rotation.eulerAngles.x, _red); top   += newLine;
            GUI.Label(new Rect(left, top, width, height), "y = " + gameObject.transform.rotation.eulerAngles.y, _green); top += newLine;
            GUI.Label(new Rect(left, top, width, height), "z = " + gameObject.transform.rotation.eulerAngles.z, _blue); top  += newLine;

            top += newLine;

            GUI.Label(new Rect(left, top, width, height), "Network Settings:", _titleStyle);
            top += newLine; top += newLine;
            GUI.Label(new Rect(left + 100, top, width, height), "UDP Address:", _normalText);
            newAddress = GUI.TextField(new Rect(Screen.width - 450, top, 400, bheight), newAddress, _buttonText);
            top       += newLine; top += newLine;
            GUI.Label(new Rect(left + 100, top, width, height), "UDP Port:", _normalText);
            newPort = GUI.TextField(new Rect(Screen.width - 450, top, 400, bheight), newPort, _buttonText);

            top += newLine; top += newLine;
            if (GUI.Button(new Rect(Screen.width - 550, top, 500, bheight), "Reset", _buttonText))
            {
                int p;
                if (int.TryParse(newPort, out p))
                {
                    port    = p;
                    address = newAddress;
                    _udp    = new UDPUnicast(address, port, sendRate);
                }
            }

            top += newLine; top += newLine;

            GUI.Label(new Rect(left, top, width, height), "Dominant Hand:", _titleStyle);
            if (GUI.Button(new Rect(Screen.width - 550, top, 500, bheight), dominantHand.ToString(), _buttonText))
            {
                if (dominantHand == DominantHandType.Right)
                {
                    dominantHand = DominantHandType.Left;
                }
                else
                {
                    dominantHand = DominantHandType.Right;
                }
            }

            top += newLine; top += newLine;
            GUI.Label(new Rect(left, top, width, height), "Reset Gyro Calibration:", _titleStyle);
            if (GUI.Button(new Rect(Screen.width - 550, top, 500, bheight), "Reset", _buttonText))
            {
                //gameObject.GetComponent<NSGyroController>().AttachGyro();
                gameObject.GetComponent <NSGyroController>().UpdateCalibration(true);
            }
        }
        else if (Click)
        {
            Vector3 e = Input.mousePosition;
            GUI.DrawTexture(new Rect(e.x - TextureSize / 2, Screen.height - e.y - TextureSize / 2, TextureSize, TextureSize), texture);
        }
    }
예제 #2
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 250, 250), ShowConfig ? Network_ON : Network_OFF, GUIStyle.none))
        {
            ShowConfig = !ShowConfig;
        }

        if (ShowConfig)
        {
            int newLine = 110;
            int width   = 1500;
            int height  = newLine;
            int bheight = height + ((int)0.5f) * height;


            int top  = 5;
            int left = 100;

            GUI.Label(new Rect(left, top, width, height), "Sending to: " + address + ":" + port, _normalText); top += newLine;
            GUI.Label(new Rect(left, top, width, height), "Gyro: " + Input.gyro.enabled, Input.gyro.enabled ? _normalText : _red); top += newLine;
            if (Input.gyro.enabled)
            {
                GUI.Label(new Rect(left, top, width, height), "Attitude: " + Input.gyro.attitude, _normalText);
            }
            top += newLine;
            if (Input.gyro.enabled)
            {
                GUI.Label(new Rect(left, top, width, height), "Rotation: " + gameObject.transform.rotation.ToString(), _normalText);
            }
            top += newLine;

            GUI.Label(new Rect(left, top, width, height), "x = " + gameObject.transform.rotation.eulerAngles.x, _red); top   += newLine;
            GUI.Label(new Rect(left, top, width, height), "y = " + gameObject.transform.rotation.eulerAngles.y, _green); top += newLine;
            GUI.Label(new Rect(left, top, width, height), "z = " + gameObject.transform.rotation.eulerAngles.z, _blue); top  += newLine;

            top += newLine;

            GUI.Label(new Rect(left, top, width, height), "Network Settings:", _titleStyle);
            top += newLine; top += newLine;
            GUI.Label(new Rect(left + 100, top, width, height), "UDP Address:", _normalText);
            newAddress = GUI.TextField(new Rect(Screen.width - 450, top, 400, bheight), newAddress, _blue2);
            top       += newLine; top += newLine;
            GUI.Label(new Rect(left + 100, top, width, height), "UDP Port:", _normalText);
            newPort = GUI.TextField(new Rect(Screen.width - 450, top, 400, bheight), newPort, _blue2);

            top += newLine; top += newLine;
            if (GUI.Button(new Rect(Screen.width - 550, top, 500, bheight), "Reset", _buttonText))
            {
                int p;
                if (int.TryParse(newPort, out p))
                {
                    port    = p;
                    address = newAddress;
                    _udp    = new UDPUnicast(address, port, sendRate);
                }
            }

            top += newLine; top += newLine;

            GUI.Label(new Rect(left, top, width, height), "Dominant Hand:", _titleStyle);
            if (GUI.Button(new Rect(Screen.width - 550, top, 500, bheight), dominantHand.ToString(), _buttonText))
            {
                if (dominantHand == DominantHandType.Right)
                {
                    dominantHand = DominantHandType.Left;
                }
                else
                {
                    dominantHand = DominantHandType.Right;
                }
            }
        }
        else
        {
            if (click)
            {
                GUI.DrawTexture(rect, activeTexture);
            }
            else
            {
                GUI.DrawTexture(rect, notActiveTexture);
            }

            if (_reset)
            {
                GUI.DrawTexture(resetRect, resetActiveTex);
            }
            else
            {
                GUI.DrawTexture(resetRect, resetNotActiveTex);
            }
        }
    }