Search Unity

How to list animations to play in the inspector?

Discussion in 'Animation' started by ekergraphics, Mar 19, 2018.

  1. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    I begun making a script with a simple
    Code (CSharp):
    1. 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
     
    Last edited: Mar 19, 2018
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
  3. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    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.
     
    theANMATOR2b likes this.