【问题标题】:how to check if a virtual camera has fully transitioned or not in C#?如何在 C# 中检查虚拟相机是否已完全过渡?
【发布时间】:2021-11-09 18:38:21
【问题描述】:

我正在处理一个 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 值,但结果仍然相同。我想在混合完成后立即运行另一个函数,所以如果有更好的解决方案,也请告诉我....

【问题讨论】:

  • 据我所知,属性应该进入StateDrivenCamera 脚本本身...

标签: c# unity3d camera cinemachine


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-06-28
    • 2011-04-24
    • 2022-08-02
    • 2018-10-17
    • 1970-01-01
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多