Add event AnimationTrack.LoadingFinished

As a programmer it is annoying working with animations because the AnimationTrack.Length property does not load with the rest of the animation. Currently, there is no way to tell when the animation has finished loading except to run a while or repeat loop that checks if the Length property is larger than 0, which is messy and inefficient. Using GetPropertyChangedSignal does not work either, the signal does not fire when the animation length loads.

A simple way to solve this would be to add an event to AnimationTracks called “LoadingFinished” or similar, to which any functionality that requires the Length property could be bound.

Other options include:

  • Adding a LoadingFinished property instead, which could be listened to using GetPropertyChangedSignal. This has the extra benefit of being able to check if it has already finished loading before trying to listen to the event.
  • Making the GetPropertyChangedSignal for Length actually fire when it loads.
  • Making it so the animation length is actually loaded as soon as the track is available.

This sounds like a bug on its own, I would’ve assumed that would work and it’s how I would’ve tried to handle this.

Does using ContentProvider:PreloadAsync work? This should yield the thread until the animation asset loads, or be instant if the asset is already loaded

1 Like

We should have an instance class that audio and animations inherit from that has an event like this. It would be much more efficient and intuitive than a repeat loop.

Afaik this was silently-added very-recently (unless my animations are coincidently all of a sudden loading after the function without any other code changes?), it was not previously a feature. This change also was not documented and it was left up to creators to find that the feature was implemented, it’s understandable if the OP was unaware of this behaviour change.

I made a feature request a couple of years back for this, would love to see APIs for when/if animations have been loaded. If not that, I’d be satisfied if GetPropertyChangedSignal worked for Length, so we can yield with an event instead of unnecessarily polling. The fact it doesn’t do anything feels unintentional.

Yeah, but this event doesn’t exist for animations, and it would be cleaner to have an inherited class for assets that take time to load.