예제 #1
0
        private void CheckKeyboard()
        {
            foreach (string code in monitoredKeys)
            {
                if (InputController.GetKeyDown(code))
                {
                    Command cmd = new Command("_sys_key");
                    cmd.ps.Add(code);
                    if (InputController.GetKey("FPS Adjustment Acceleration"))
                    {
                        cmd.pi.Add(10);
                    }
                    else
                    {
                        cmd.pi.Add(1);
                    }
                    CommandSender.Send(cmd);
                }
            }

            if (InputController.GetKeyDown("Render FPS -"))
            {
                skipRate++;
            }
            if (InputController.GetKeyDown("Render FPS +"))
            {
                if (skipRate > 1)
                {
                    skipRate--;
                }
            }

            if (InputController.GetKeyDown("Reset Scene"))
            {
                foreach (string name in groupNames)
                {
                    var group = GameObject.Find(name);
                    if (group)
                    {
                        GameObject.Destroy(group);
                    }
                }
                groupNames.Clear();
            }
        }
예제 #2
0
        void Update()
        {
            if (InputController.GetKeyDown("Reset Scene"))
            {
                FPSTextBox.PhysicalPaused = 0;
                FPSTextBox.MaxPhysicalFPS = 0;
                FPSTextBox.PhysicalFPS    = 0;
            }
            if (InputController.GetKeyDown("Show / Hide UI"))
            {
                showUI = !showUI;
            }

            if (!showUI)
            {
                if (physicalFPSTextObj)
                {
                    physicalFPSTextObj.SetActive(false);
                }
                if (renderFPSTextObj)
                {
                    renderFPSTextObj.SetActive(false);
                }
                return;
            }
            else
            {
                if (physicalFPSTextObj)
                {
                    physicalFPSTextObj.SetActive(true);
                }
                if (renderFPSTextObj)
                {
                    renderFPSTextObj.SetActive(true);
                }
            }

            int posY = -20;

            if (MaxPhysicalFPS > 0)
            {
                string txt = $"Physical: {PhysicalFPS} / {MaxPhysicalFPS} PF/s";
                if (PhysicalPaused == 1)
                {
                    txt += "  <b><color=#FF8888>Paused</color></b>";
                }

                physicalFPSTextObj.GetComponent <Text>().text = txt;
                physicalFPSTextObj.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, posY);
                posY -= 20;
            }
            else
            {
                physicalFPSTextObj.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 60);
            }

            int fps = Mathf.CeilToInt(1.0f / Time.deltaTime);

            renderFPSTextObj.GetComponent <Text>().text = $"Render: {(fps + (fps & 1)) / KinematicsServer.instance.skipRate} RF/s";
            renderFPSTextObj.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, posY);
        }