Ejemplo n.º 1
0
    void Start()
    {
        guiBackground = (Texture2D)Resources.Load("GUIBackground");
        _readXml      = this.GetComponent <URGData>();

        if (MainUST)
        {
            touchArea.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1f);
        }
        else
        {
            touchArea.SetActive(false);
        }


        _readXml.init();


        if (Enable)
        {
            urg = UrgDevice.GetComponent <Urg>();
            urg.init();

            data.urgPosOffsetx = PlayerPrefs.GetFloat(USTObjs_Name + " URG Offset X");
            data.urgPosOffsety = PlayerPrefs.GetFloat(USTObjs_Name + " URG Offset Y");
            data.urgScalex     = PlayerPrefs.GetFloat(USTObjs_Name + " Scalex", data.urgScalex);
            data.urgScaley     = PlayerPrefs.GetFloat(USTObjs_Name + " Scaley", data.urgScaley);

            data.urgRotate = PlayerPrefs.GetFloat(USTObjs_Name + " Rotate", data.urgRotate);

            data.guiScale = PlayerPrefs.GetInt(USTObjs_Name + " GUI Scale");

            urg.PosOffset = new Vector3(data.urgPosOffsetx, data.urgPosOffsety);
            urg._Scale    = new Vector3(data.urgScalex, data.urgScaley);
            urg.Rotate    = data.urgRotate;

            if (MainUST)
            {
                data.TAoffPosx  = PlayerPrefs.GetFloat(USTObjs_Name + "Touch AreaPosX");
                data.TAoffPosy  = PlayerPrefs.GetFloat(USTObjs_Name + "Touch AreaPosY");
                data.scaleRatex = PlayerPrefs.GetFloat(USTObjs_Name + "Touch Width");
                data.scaleRatey = PlayerPrefs.GetFloat(USTObjs_Name + "Touch Height");

                TAoffPos.x  = data.TAoffPosx;
                TAoffPos.y  = data.TAoffPosy;
                scaleRate.x = data.scaleRatex;
                scaleRate.y = data.scaleRatey;
            }

            urg.DrawMesh = false;

            if (urg != null)
            {
                urg.Connect();
            }

            px = urg.PosOffset.x;
            py = urg.PosOffset.y;

            scalex = urgScale.x;
            scaley = urgScale.y;

            _style.fontSize = data.guiScale;
        }
        else
        {
            if (MainUST)
            {
                touchArea.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0f);
            }
        }
    }
Ejemplo n.º 2
0
        void OnGUI()
        {
            if (showGui)
            {
                GUIStyle      style      = new GUIStyle();
                GUIStyleState styleState = new GUIStyleState();
                styleState.background = guiBackground;
                styleState.textColor  = Color.white;
                style.normal          = styleState;

                GUILayout.BeginArea(new Rect(0, 0, 300, Screen.height), style);

                var urgStatus = urg.IsConnected ? "Connected" : "Not Connected";
                GUILayout.Label("URG Status :  " + urgStatus);

                urg.DrawMesh = GUILayout.Toggle(urg.DrawMesh, "Show URG Data");

                if (GUILayout.Button("Connect"))
                {
                    urg.Connect();
                }

                if (GUILayout.Button("Disconnect"))
                {
                    urg.Disconnect();
                }

                if (GUILayout.Button("Reload"))
                {
                    if (urg.IsConnected)
                    {
                        urg.Disconnect();
                    }
                    UnityEngine.SceneManagement.SceneManager.LoadScene(0);
                }

                GUILayout.Space(30);

                Vector3 pos = new Vector3();
                GUILayout.Label("URG Offset X :  " + urg.PosOffset.x);
                pos.x = GUILayout.HorizontalSlider(urg.PosOffset.x, -20, 20);

                GUILayout.Label("URG Offset Y :  " + urg.PosOffset.y);
                pos.y         = GUILayout.HorizontalSlider(urg.PosOffset.y, -60, 60);
                urg.PosOffset = pos;

                //GUILayout.Label("Scale :  " + urg.Scale.ToString("0.000"));
                //urg.Scale = GUILayout.HorizontalSlider(urg.Scale, 0.001f, 0.2f);

                GUILayout.Label("Scale x:  " + urg._Scale.x.ToString("0.000"));
                urgScale.x = GUILayout.HorizontalSlider(urg._Scale.x, 0.001f, 0.2f);

                GUILayout.Label("Scale y:  " + urg._Scale.y.ToString("0.000"));
                urgScale.y = GUILayout.HorizontalSlider(urg._Scale.y, 0.001f, 0.2f);
                urg._Scale = urgScale;

                GUILayout.Space(30);

                GUILayout.Label("Waterfall Size X :  " + waterfallSize.x);
                waterfallSize.x = GUILayout.HorizontalSlider(waterfallSize.x, 1, 30);

                GUILayout.Label("Waterfall Size Y :  " + waterfallSize.y);
                waterfallSize.y = GUILayout.HorizontalSlider(waterfallSize.y, 10, 100);

                GUILayout.Label("Waterfall Size Z :  " + waterfallSize.z);
                waterfallSize.z = GUILayout.HorizontalSlider(waterfallSize.z, 1, 20);

                GUILayout.Space(30);

                GUILayout.Label("G :  " + g);
                g = GUILayout.HorizontalSlider(g, 0.1f, 20);

                GUILayout.Label("Jet  : " + jet);
                jet = GUILayout.HorizontalSlider(jet, 0, 1f);

                GUILayout.Label("Drop Duration :  " + duration.x.ToString("0.00") + "  ~  " + duration.y.ToString("0.00"));
                GUILayout.BeginHorizontal();
                duration.x = GUILayout.HorizontalSlider(duration.x, 1, 20);
                duration.y = GUILayout.HorizontalSlider(duration.y, 1, 40);
                GUILayout.EndHorizontal();

                GUILayout.Label("Splash Duration :  " + duration.z.ToString("0.00") + "  ~  " + duration.w.ToString("0.00"));
                GUILayout.BeginHorizontal();
                duration.z = GUILayout.HorizontalSlider(duration.z, 1, 20);
                duration.w = GUILayout.HorizontalSlider(duration.w, 1, 40);
                GUILayout.EndHorizontal();

                GUILayout.Label("Drop Size :  " + dropSize.ToString("0.000"));
                dropSize = GUILayout.HorizontalSlider(dropSize, 0.0005f, 0.2f);

                GUILayout.Label("Splash Size :  " + splashSize.ToString("0.000"));
                splashSize = GUILayout.HorizontalSlider(splashSize, 0.0001f, 0.1f);

                GUILayout.Space(30);

                GUILayout.Label("Collision Range :  " + collisionParams.w);
                collisionParams.w = GUILayout.HorizontalSlider(collisionParams.w, 0, 1.0f);

                GUILayout.Label("After Collision Speed Multiplier X :  " + collisionParams.x);
                collisionParams.x = GUILayout.HorizontalSlider(collisionParams.x, 0, 1000.0f);

                GUILayout.Label("After Collision Speed Multiplier Y :  " + collisionParams.y);
                collisionParams.y = GUILayout.HorizontalSlider(collisionParams.y, 0.0001f, 30.0f);

                GUILayout.Label("After Collision Speed Multiplier Z :  " + collisionParams.z);
                collisionParams.z = GUILayout.HorizontalSlider(collisionParams.z, 0.0001f, 3.0f);

                GUILayout.Label("Drop Count :  " + (maxDropsCount - GetActiveBufferSize(dropsPoolBuffer)) + " / " + maxDropsCount);
                GUILayout.Label("FPS : " + (1 / Time.deltaTime).ToString("0.00"));

                GUILayout.EndArea();
            }
        }
Ejemplo n.º 3
0
    void Update()
    {
        if (Input.GetKeyDown("/"))
        {
            showMouse = !showMouse;
        }

        if (showMouse)
        {
            Cursor.visible = true;
        }
        else
        {
            Cursor.visible = false;
        }


        if (Input.GetKeyDown(ShowSetting))
        {
            showGui = !showGui;
        }

        if (Enable && MainUST)
        {
            touchAreaFuct();
        }

        if (showGui)
        {
            if (Input.GetKeyDown(KeyCode.F8))
            {
                print("URG disconnect");
                urg.Disconnect();
            }
            if (Input.GetKeyDown(KeyCode.F7))
            {
                print("URG connect");
                urg.Connect();
            }
            if (Input.GetKeyDown(KeyCode.F12))
            {
                print("Default data.");
                Default();
            }



            if (Input.GetKey(KeyCode.UpArrow))
            {
                py += step;
                Vector3 pos = new Vector3(urg.PosOffset.x, py, urg.PosOffset.z);
                urg.PosOffset = pos;
            }
            if (Input.GetKey(KeyCode.DownArrow))
            {
                py -= step;
                Vector3 pos = new Vector3(urg.PosOffset.x, py, urg.PosOffset.z);
                urg.PosOffset = pos;
            }
            if (Input.GetKey(KeyCode.LeftArrow))
            {
                px -= step;
                Vector3 pos = new Vector3(px, urg.PosOffset.y, urg.PosOffset.z);
                urg.PosOffset = pos;
            }
            if (Input.GetKey(KeyCode.RightArrow))
            {
                px += step;
                Vector3 pos = new Vector3(px, urg.PosOffset.y, urg.PosOffset.z);
                urg.PosOffset = pos;
            }


            if (Input.GetKey(KeyCode.Z))
            {
                scalex -= step_scale;
                Vector3 pos = new Vector3(scalex, urg._Scale.y, urg._Scale.z);
                urg._Scale = pos;
            }

            if (Input.GetKey(KeyCode.X))
            {
                scalex += step_scale;
                Vector3 pos = new Vector3(scalex, urg._Scale.y, urg._Scale.z);
                urg._Scale = pos;
            }



            if (Input.GetKey(KeyCode.A))
            {
                scaley -= step_scale;
                Vector3 pos = new Vector3(urg._Scale.x, scaley, urg._Scale.z);
                urg._Scale = pos;
            }

            if (Input.GetKey(KeyCode.S))
            {
                scaley += step_scale;
                Vector3 pos = new Vector3(urg._Scale.x, scaley, urg._Scale.z);
                urg._Scale = pos;
            }

            if (Input.GetKey(KeyCode.C))
            {
                rot       -= step_rotate * Time.deltaTime;
                urg.Rotate = rot;
            }

            if (Input.GetKey(KeyCode.V))
            {
                rot       += step_rotate * Time.deltaTime;
                urg.Rotate = rot;
            }

            if (Input.GetKeyDown("="))
            {
                step        *= 1.25f;
                step_scale  *= 1.25f;
                step_rotate *= 1.25f;
            }
            if (Input.GetKeyDown("-"))
            {
                step        /= 1.25f;
                step_scale  /= 1.25f;
                step_rotate /= 1.25f;
            }
            if (Input.GetKeyDown(KeyCode.P))
            {
                Debug.Log("toucharea value: " + touchArea_value);
            }
        }
    }