SetAnimatorAtEndOfFrame - Set Twice?
Posted: Tue Feb 22, 2022 5:40 pm
I was just wondering why this code sets the animator controller/portrait active twice?
I'm tracking down an issue (probably unique to our game) where once in a long while, there will be a single frame where the NPC portrait is not set to anything and shows a big white rectangle. I thought maybe when I got rid of this, it caused the issue. Just curious if that could be.
I'm tracking down an issue (probably unique to our game) where once in a long while, there will be a single frame where the NPC portrait is not set to anything and shows a big white rectangle. I thought maybe when I got rid of this, it caused the issue. Just curious if that could be.
Code: Select all
protected virtual IEnumerator SetAnimatorAtEndOfFrame(RuntimeAnimatorController animatorController)
{
if (animator.runtimeAnimatorController != animatorController)
{
animator.runtimeAnimatorController = animatorController;
}
if (animatorController != null)
{
Tools.SetGameObjectActive(portraitImage, portraitImage.sprite != null);
}
yield return new WaitForEndOfFrame();
if (animator.runtimeAnimatorController != animatorController)
{
animator.runtimeAnimatorController = animatorController;
}
if (animatorController != null)
{
Tools.SetGameObjectActive(portraitImage, portraitImage.sprite != null);
}
}