Cinemachine IsBlending and Coroutine
Hello everybody! I'm trying to write a coroutine that executes instructions after Cinemachine Brain is over with a blend. The problem is that sometimes the code works and others it doesn't and I'm unable to find where the bug starts.
private IEnumerator SetVCamActive(bool state)
{
yield return new WaitUntil(() => m_cameraBrain.IsBlending == false);
m_vCameraFar.transform.parent.gameObject.SetActive(state);
}
My aim is I want to deactivate the virtual cam, only after the last blend was completed. I can see on Update with a Debug.Log that IsBlending actually changes its value. It seems like it's jumping the yield and executing the second instruction before the WaitUntil has its condition verified.
I also tried this code, but it gives the same results.
private IEnumerator SetVCamActive(bool state)
{
while (m_cameraBrain.IsBlending)
{
yield return null;
}
m_vCameraFar.transform.parent.gameObject.SetActive(state);
}
Any help is appreciated. Thanks
Filippo
Your answer
Follow this Question
Related Questions
Changing order in layers at runtime with a coroutine 0 Answers
Issue with coroutine 0 Answers
unity 5 stopping 0 Answers
Custom Coroutine With Arguments 1 Answer
Using coroutine and texture array to randomly associate textures? 1 Answer