Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[unity] Timeline clip not updating to the shown EaseIn & MixerBehaviour null check #1962

Closed
Jamez0r opened this issue Oct 7, 2021 · 2 comments
Assignees
Labels

Comments

@Jamez0r
Copy link

Jamez0r commented Oct 7, 2021

Regarding this post on the forums: http://esotericsoftware.com/forum/Spine-4-Timeline-Extension-Pausing-at-end-of-track-16190

The new EaseIn/EmptyAnimations functionality for Timeline is working great.

Found two minor issues:

Issue 1

If a Spine Animation Track does not have a bound target (no target SkeletonAnimation to apply the track to) then a null reference error is thrown on HandleClipEnd(). I added a null-check (the highlighted part in the screenshot below) and that appeared to fix it.
mixer null check

Issue 2

This one is easier to explain with a video: https://youtu.be/DPnQfnWYxVo
If you adjust the EaseIn, it shows the MixDuration value updating along with it, but it doesn't seem to apply it to some internal value for the actual Mix Duration. Unchecking/checking the Custom Duration toggle updates the internal value.

Thanks a lot!!

@Jamez0r
Copy link
Author

Jamez0r commented Oct 8, 2021

Did some further testing on Issue 2 -

My understanding of the issue:

Disclaimer - I'm not an expert with Timeline stuff, but I have created a few Tracks/Clips/Markers.

Also Note: I have been doing pretty much all of my testing with the game running in Play Mode.

While the game is running, modifications through code (not by clicking/doing stuff in the Inspector) to the MixDuration value cause it to show the updated value in the Inspector, but not actually apply/save it. So when the EaseIn value is changed by dragging the left edge of the clip, the MixDuration shows the updated value in the inspector but when the director is played and the animation for the clip is executed, the old value is still used.

If you make any change in the clip's Inspector (like how I mentioned unchecking and rechecking the Custom Duration toggle, but really any change to anything does it), the clip gets Dirtied (or whatever the equivalent to that is for Timeline), and the value of MixDuration shown in the Inspector gets applied/saved.

Even though the SpineAnimationStateClipInspector calls EditorUtility.SetDirty(targetClip), which you'd expect to save/apply any changes to the MixDuration, it doesn't seem to save/update the value while the game is running.

Idea for Solution:

If there is no way to force the save/apply to the MixDuration value, then maybe instead of simply referencing the MixDuration when the animation is applied in ProcessFrame (on MixerBehaviour) we could instead 'calculate' the MixDuration at that time:

public float GetCustomMixDuration(SpineAnimationStateBehaviour clipData) {
    if (clipData.useBlendDuration) {
        return System.Math.Max(THE_CLIPS_BLEND_IN_DURATION, THE_CLIPS_EASE_IN_DURATION);
    } else {
        return clipData.mixDuration;
    }
}

The problem here was that the TimelineClip is not available in the MixerBehaviour to find out what the current ease-in/blend-in values are.

The (Potentially Hacky) Reference to TimelineClip:

This Unity Forum post (the response by LaurensMMonk) has an example of how to reference the TimelineClip from the MixerBehaviour: https://forum.unity.com/threads/how-to-access-the-clip-timing-start-end-time-in-playablebehaviour-functions.494344/#post-3861688

I applied this technique to the SpineAnimationStateTrack/Clip/Mixer/Behaviour/etc and it does indeed allow you to reference the TimelineClip. I haven't super thoroughly tested it (haven't tried it in a Build or anything like that), and since I don't know the ins-and-outs of the Timeline API, maybe using this technique is a bit of a "hack"? Not too sure, but as far as I can tell the functionality of it works.

So with this setup, if Custom Duration and Use Blend Duration are enabled and you drag the left edge of the clip to modify the Ease-In, the new value is shown in the inspector (as it was previously) and is also 'calculated' when you play the director. If you disable Use Blend Duration, then the Mix Duration value is used, and if you then modify the Mix Duration in the Inspector, it applies/saves it, so that also seems to work fine.

I also did not find any issues with Entering/Exiting Play Mode. If the game was Playing and I dragged to modify the Ease-In value, and then immediately exited Play Mode, the new value was still present on the clip and in the inspector.

Here are the scripts that I modified, its essentially just the TimelineClip related stuff from the post I linked above, and then calling that new GetCustomMixDuration() as needed in the MixerBehaviour script. I put a comment of "//James Modification" everywhere that I made changes.
Modified Spine-Timeline Scripts.zip

Again, I'm not sure if this is a hacky way of referencing the TimelineClip or not, so no worries if this isn't a good solution!

@HaraldCsaszar
Copy link
Collaborator

Thanks very much for reporting! Fixed, new 4.0 Spine Timeline UPM package is available for download:
http://esotericsoftware.com/spine-unity-download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants