Unity Cinemachine error: Assertion failed on expression: 'CompareApproximately(det, 1.0F, .005f)'

时间:2019-03-17 22:40:42

标签: unity3d

I am using the Cinemachine asset available on the Unity Asset Store and getting a bunch of exceptions. Although they don't seem to have any effect on my game as such, but still I'd prefer to get rid of them. The exceptions appear only when I unpause a paused game (using Time.timeScale), and not otherwise.

enter image description here

Stack trace of exceptions below:

Assertion failed: Assertion failed on expression: 'CompareApproximately(det, 1.0F, .005f)'

UnityEngine.Quaternion:FromToRotation(Vector3, Vector3)

Cinemachine.Utility.PositionPredictor:PredictPosition(Single) (at Assets/Cinemachine/Base/Runtime/Core/Predictor.cs:64)

Cinemachine.CinemachineFramingTransposer:MutateCameraState(CameraState&, Single) (at Assets/Cinemachine/Base/Runtime/Components/CinemachineFramingTransposer.cs:318)

Cinemachine.CinemachineVirtualCamera:CalculateNewState(Vector3, Single) (at Assets/Cinemachine/Base/Runtime/Behaviours/CinemachineVirtualCamera.cs:426)

Cinemachine.CinemachineVirtualCamera:UpdateCameraState(Vector3, Single) (at Assets/Cinemachine/Base/Runtime/Behaviours/CinemachineVirtualCamera.cs:128)

Cinemachine.CinemachineCore:UpdateVirtualCamera(ICinemachineCamera, Vector3, Single) (at Assets/Cinemachine/Base/Runtime/Core/CinemachineCore.cs:237)

Cinemachine.CinemachineCore:UpdateAllActiveVirtualCameras(Vector3, Single) (at Assets/Cinemachine/Base/Runtime/Core/CinemachineCore.cs:165)

Cinemachine.CinemachineBrain:UpdateVirtualCameras(UpdateFilter, Single) (at Assets/Cinemachine/Base/Runtime/Behaviours/CinemachineBrain.cs:445)

Cinemachine.CinemachineBrain:LateUpdate() (at Assets/Cinemachine/Base/Runtime/Behaviours/CinemachineBrain.cs:399)

Below is the script responsible for pausing and unpausing the game:

public void PauseGame()
{
    if (pauseMenuCanvas)
    {
        Time.timeScale = 0f;
        pauseKeyDisabled = true;
        if (pauseMenuPanel)
        {
            pauseMenuPanel.SetActive(true);
            pauseMenuPanel.GetComponent<CanvasGroup>().interactable = true;
            if (pauseMenuPanelAnimator == null)
                pauseMenuPanelAnimator = pauseMenuPanel.GetComponent<Animator>();
            pauseMenuPanelAnimator.SetTrigger("Open");
            if (!helptextPopulated)
            {
                helptextPopulated = true;
                helptext.text += "\n\n<align=left>" + GameSession.contentInfotext;
            }
        }
    }
    gamePaused = true;
    pauseKeyDisabled = false;
}
IEnumerator UnPauseCoRoutine()
{
    pauseKeyDisabled = true;
    Time.timeScale = 1;

    if (pauseMenuPanel.activeSelf)
    {
        pauseMenuPanelAnimator.SetTrigger("Close");
        pauseMenuPanel.GetComponent<CanvasGroup>().interactable = false;
    }
    if (helpPanel.activeSelf)
    {
        if (helpPanelAnimator == null)
        {
            helpPanelAnimator = helpPanel.GetComponent<Animator>();
            helpPanel.GetComponent<CanvasGroup>().interactable = false;
        }
        helpPanelAnimator.SetTrigger("Close");
    }
    if (audioPanel.activeSelf)
    {
        if (audioPanelAnimator == null)
        {
            audioPanel.GetComponent<CanvasGroup>().interactable = false;
            audioPanelAnimator = audioPanel.GetComponent<Animator>();
        }
        audioPanelAnimator.SetTrigger("Close");
    }
    RuntimeAnimatorController ac = pauseMenuPanelAnimator.runtimeAnimatorController;
    yield return new WaitForSeconds(ac.animationClips[0].length); // use any animation from the array, as all have same length
    pauseMenuPanel.SetActive(false);
    helpPanel.SetActive(false);
    audioPanel.SetActive(false);
    gamePaused = false;
    pauseKeyDisabled = false;
}

0 个答案:

没有答案