Ejemplo n.º 1
0
    /// <summary>
    /// Update the cursor based on how long the back button is pressed
    /// </summary>
    void UpdateCursor(float timerRotateRatio)
    {
        if (InstantiatedCursorTimer != null)
        {
            InstantiatedCursorTimer.renderer.enabled = true;

            // Clamp the rotation ratio to avoid rendering artifacts
            float alphaAmount = Mathf.Clamp(1.0f - timerRotateRatio, 0.0f, 1.0f);
            CursorTimerMaterial.SetFloat("_Cutoff", alphaAmount);

            // Draw timer at fixed distance in front of camera
            Vector3 cameraPosition = Vector3.zero;
            Vector3 cameraForward  = Vector3.forward;
            if (cameraController.GetCameraForward(ref cameraForward) &&
                cameraController.GetCameraPosition(ref cameraPosition))
            {
                // cursor positions itself based on camera forward and draws at a fixed depth
                InstantiatedCursorTimer.transform.position = cameraPosition + (cameraForward * fixedDepth);
                InstantiatedCursorTimer.transform.forward  = cameraForward;
            }
        }
    }