Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (rotating)
        {
            // Get rotation delta
            float previousAngle = rotationCurve.Evaluate(rotationValue / rotationTime);
            rotationValue += Time.deltaTime;
            if (rotationValue > 1)
            {
                rotating      = false;
                rotationValue = 1;
            }
            float newAngle      = rotationCurve.Evaluate(rotationValue / rotationTime);
            float rotationDelta = (newAngle - previousAngle) * totalDesiredRotationDelta;

            // Rotate around y axis
            transform.Rotate(Vector3.up, rotationDelta, Space.Self);
        }
        else
        {
            if (Input.GetKeyDown("right") || MobileInput.GetSwipedLeft())
            {
                RotateToNextObject();
            }
            else if (Input.GetKeyDown("left") || MobileInput.GetSwipedRight())
            {
                RotateToPreviousObject();
            }
            else if (Input.GetKeyDown("space") || Input.GetKeyDown("enter") || Input.GetMouseButtonDown(0) || MobileInput.GetTouchUp())
            {
                menuOptions[selectedMenuOption].PerformAction();
            }
        }
    }