How to list animations to play in the inspector?

I begun making a script with a simple public List<GameObject> ObjectsToAnimate; where a designer can drop a number of objects.

Right beside that list, I then wish to display a drop-down menu populated by any animations I can find in those objects, selectable in the inspector by a designer.

I find it very difficult to find help on this topic, due to many results showing examples from the legacy animation system (as seen here, for example), and also, I oddly find a lot of conflicting results on how to create a drop-down list (do I override OnGUI or OnInspectorGUI for example). Is there anyone who can point me in the right direction here?

Here is an example of a recent solution, but I thought that AnimationClip is part of the legacy

This question is probably better asked in scripting but here are a couple links that may help.

I think scriptable objects are more for ‘in-game’ content - but here is the link - in case I’m wrong.

Thank you for the quick response!

I ended up using this asset to hard link a GameObject to an AnimationClip, which means that the designer need to pick a GameObject from the scene first, and then a .anim from the Project folders second, which isn’t super clean, but it will do for now.

The drop-down menu of available animations will have to wait for another day.

1 Like