Exemplo n.º 1
0
 private void HandleKeyPress()
 {
     if (InputController.GetKey("Camera Latitude +"))
     {
         latitude = Mathf.Clamp(latitude + latitudeAdjustmentStep, -Mathf.PI / 2, Mathf.PI / 2);
     }
     if (InputController.GetKey("Camera Latitude -"))
     {
         latitude = Mathf.Clamp(latitude - latitudeAdjustmentStep, -Mathf.PI / 2, Mathf.PI / 2);
     }
     if (InputController.GetKey("Camera Longitude -"))
     {
         longitude -= longitudeAdjustmentStep;
         if (longitude < 0)
         {
             longitude += Mathf.PI * 2;
         }
         if (longitude > Mathf.PI * 2)
         {
             longitude -= Mathf.PI * 2;
         }
     }
     if (InputController.GetKey("Camera Longitude +"))
     {
         longitude += longitudeAdjustmentStep;
         if (longitude < 0)
         {
             longitude += Mathf.PI * 2;
         }
         if (longitude > Mathf.PI * 2)
         {
             longitude -= Mathf.PI * 2;
         }
     }
     if (InputController.GetKey("Camera Radius +"))
     {
         sphereRadius += radiusAdjustmentStep;
     }
     if (InputController.GetKey("Camera Radius -"))
     {
         sphereRadius -= radiusAdjustmentStep;
     }
     if (InputController.GetKey("Camera Center Downward"))
     {
         sphereCenterOffset.y -= offsetAdjustmentStep;
     }
     if (InputController.GetKey("Camera Center Upward"))
     {
         sphereCenterOffset.y += offsetAdjustmentStep;
     }
     if (InputController.GetKey("Camera Center Forward"))
     {
         sphereCenterOffset += new Vector3(transform.forward.x, 0, transform.forward.z).normalized *offsetAdjustmentStep;
     }
     if (InputController.GetKey("Camera Center Backward"))
     {
         sphereCenterOffset -= new Vector3(transform.forward.x, 0, transform.forward.z).normalized *offsetAdjustmentStep;
     }
     if (InputController.GetKey("Camera Center Leftward"))
     {
         sphereCenterOffset -= new Vector3(transform.right.x, 0, transform.right.z).normalized *offsetAdjustmentStep;
     }
     if (InputController.GetKey("Camera Center Rightward"))
     {
         sphereCenterOffset += new Vector3(transform.right.x, 0, transform.right.z).normalized *offsetAdjustmentStep;
     }
 }
Exemplo n.º 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);
        }