Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        //Update timescale based on UI
        if (!inptTime.isFocused)
        {
            float roundedTime = (Time.timeScale / PhysicsEngine.TIMESCALER) * 100.0f;
            roundedTime   = Mathf.Round(roundedTime) / 100.0f;
            inptTime.text = (roundedTime).ToString();
        }

        //Show/Hide UI
        if (Input.GetKeyDown(KeyCode.F1))
        {
            // Disable this control in pause menu
            if (pausePanel.activeSelf)
            {
                return;
            }

            if (showUI)
            {
                canvasGroup.alpha          = 0.0f;
                canvasGroup.blocksRaycasts = false;
            }
            else
            {
                canvasGroup.alpha          = 1.0f;
                canvasGroup.blocksRaycasts = true;
            }
            showUI = !showUI;
        }
        //Pause
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (!pausePanel.activeSelf)
            {
                PauseGame();
            }
            else
            {
                ResumeGame();
            }
        }
        //Delete
        if (Input.GetKeyDown(KeyCode.Delete))
        {
            foreach (GameObject _obj in selectedEntites)
            {
                Destroy(_obj);
            }
        }

        // Adjust timescale
        if (scalingTime)
        {
            float timeSpentScaling = Time.realtimeSinceStartup - scalingTimeStart;

            float ammount = 0.5f * timeSpentScaling;

            ammount *= scalingTimeDirection;

            physicsEngine.AddjustTimeScale(ammount);
        }

        // Track middle mouse hold time
        if (Input.GetMouseButton(2))
        {
            middleMouseHoldTime += Time.unscaledDeltaTime;
        }
        else
        {
            middleMouseHoldTime = 0.0f;
        }

        // // Track mouse scrolling
        // mouseScroll = Input.mouseScrollDelta.y;
    }