Portrait animator skipping first frame
-
- Posts: 222
- Joined: Wed Jan 22, 2020 10:48 pm
Portrait animator skipping first frame
I just noticed that the portrait animators are skipping the first frames of their animations. I was digging through the code and I don't see anything wrong. I'm wondering if anyone else has run into this, or is this some peculiarity with mechanim? Like, does it skip the first frame after activation or swapping runtime controllers or something?
Re: Portrait animator skipping first frame
I don't see that here. Is it possible that your subtitle panel is playing a Show or Focus animation that's hiding the portrait animator until it's done?
-
- Posts: 222
- Joined: Wed Jan 22, 2020 10:48 pm
Re: Portrait animator skipping first frame
The only reason I caught this was because my images that are animated are big white squares when they're not being animated. I think this may be a bug with unity's animator unless I've lost my mind.
The very first frame a new runtimecontroller is set (or the object becomes active), the portrait animator isn't animating. The only way I've been able to force it to update on the first frame is by adding this:
StandardUISubtitlePanel
I'm not sure what's going on, but I've filed a bug with Unity. If they have any guidance I'll share it here. I don't think it's a bug with DSU.
Incidentally, why is that double assignment there before and after end of frame?
The very first frame a new runtimecontroller is set (or the object becomes active), the portrait animator isn't animating. The only way I've been able to force it to update on the first frame is by adding this:
StandardUISubtitlePanel
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);
}
animator.Update(0f);<---
}
I'm not sure what's going on, but I've filed a bug with Unity. If they have any guidance I'll share it here. I don't think it's a bug with DSU.
Incidentally, why is that double assignment there before and after end of frame?
Re: Portrait animator skipping first frame
The double assignment handles an edge case where a panel animation affects the portrait animator.
Does it work if you move "animator.Update(0f);" to run before the yield? If so, I'll add that to the script.
Does it work if you move "animator.Update(0f);" to run before the yield? If so, I'll add that to the script.
-
- Posts: 222
- Joined: Wed Jan 22, 2020 10:48 pm
Re: Portrait animator skipping first frame
Sorry for the late reply! Ahh gotcha (RE: edge case).
I think I found out what the issue is. The sequencer opens subtitles on LateUpdate which happens after animation takes place. Was the sequencer modified recently to switch to LateUpdate or something? I don't remember having this issue, and I know I upgraded DSU at some point.
EDIT:
I think I found it! There was a recent update to Sequencer.cs
I reverted that portion of the file and that fixed the issue.
I think I found out what the issue is. The sequencer opens subtitles on LateUpdate which happens after animation takes place. Was the sequencer modified recently to switch to LateUpdate or something? I don't remember having this issue, and I know I upgraded DSU at some point.
EDIT:
I think I found it! There was a recent update to Sequencer.cs
Code: Select all
CheckQueuedCommands();
+ }
+ }
+
+ public void LateUpdate()
+ {
+ if (m_isPlaying)
+ {
CheckActiveCommands();
if (m_delayTimeLeft > 0)
{
switch (DialogueTime.mode)
{
case DialogueTime.TimeMode.Realtime:
m_delayTimeLeft -= Time.unscaledDeltaTime;
break;
case DialogueTime.TimeMode.Gameplay:
m_delayTimeLeft -= Time.deltaTime;
break;
- }
+ }
}
if ((m_queuedCommands.Count == 0) && (m_activeCommands.Count == 0) && m_delayTimeLeft <= 0)
{
FinishSequence();
}
}
}
I reverted that portion of the file and that fixed the issue.
Re: Portrait animator skipping first frame
Thanks for identifying that. I made the change to handle ->Message() and @Message() timing per this post. But it created the issue you're reporting. I'm going to evaluate moving it back to Update() and queueing up messages to be handled in LateUpdate() rather than doing them at the same time.
-
- Posts: 222
- Joined: Wed Jan 22, 2020 10:48 pm
Re: Portrait animator skipping first frame
Ahhh gotcha! Sweet, well let me know if you want me to test anything out. For now, I'll just revert those few lines in our build.
Re: Portrait animator skipping first frame
Sounds good. Count on it being reverted to Update() in version 2.2.21, with messages probably in LateUpdate() to accommodate CHOPJZL's request in the other thread.
If you ever suspect something has changed in an update, give the Release Notes a quick skim. It might be faster than digging through file diffs.
If you ever suspect something has changed in an update, give the Release Notes a quick skim. It might be faster than digging through file diffs.
-
- Posts: 222
- Joined: Wed Jan 22, 2020 10:48 pm
Re: Portrait animator skipping first frame
I recently updated to the latest DS and noticed that this bug has returned. I was looking at LateUpdate again and see that it's been changed.
If I want to go back to working the old way, should I just delete this again:
If I want to go back to working the old way, should I just delete this again:
Code: Select all
}
}
public void LateUpdate()
{
if (m_isPlaying)
{
foreach (string message in queuedMessages)
{
Sequencer.Message(message);
}
queuedMessages.Clear();
Re: Portrait animator skipping first frame
Hi,
Version 2.2.22 now only sends queued-up messages in LateUpdate. Are you using messages in the sequence when you see this issue?
In any case, you could revert that to address it in the interim. I'd like to get to the bottom of this. If nothing else, I can add a conditional define to send this messages in Update() instead of LateUpdate() so you won't have to edit Sequencer.cs.
Version 2.2.22 now only sends queued-up messages in LateUpdate. Are you using messages in the sequence when you see this issue?
In any case, you could revert that to address it in the interim. I'd like to get to the bottom of this. If nothing else, I can add a conditional define to send this messages in Update() instead of LateUpdate() so you won't have to edit Sequencer.cs.