0

我正在做一个 C#/Unity 项目,我想知道 Cinemachine 虚拟相机何时完全过渡到另一个 Cinemachine 相机。我见过有人使用IsBlending,但我仍然不确定如何在我的项目中实现该代码。

我的代码就像..

  private CinemachineBlend activeBlend = null;
  public bool IsBlending { get { return activeBlend != null; } }
  [SerializeField] private CinemachineVirtualCamera[] virtualCameras;

  void TestItIsWorking()
  {
    virtualCameras[0].Priority = 10;
    virtualCameras[1].Priority = 0; // -> this starts the blending the virtual camera
    Debug.Log("this function is called"); // -> prints "this function is called"
    Debug.Log(IsBlending); // -> prints false
  }

所以我想我做错了什么,因为虚拟相机已经开始改变,我得到一个错误的值作为 IsBlending 布尔值。我还编写了 while 循环,而不仅仅是 Debug 记录 IsBlending 值,但结果仍然相同。我想在混合完成后立即运行另一个函数,所以如果有更好的解决方案,也请告诉我......

4

1 回答 1

0

您确定您的 activeBlend 字段正确获得参考吗?顺便说一下,使用 CinemachineBrain 的 IsBlending 属性是一种选择。

于 2021-09-14T16:37:21.163 回答