Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Too Long Animations List in Inspector

Discussion in 'Animation' started by ptm_oo, May 10, 2020.

  1. ptm_oo

    ptm_oo

    Joined:
    Oct 30, 2014
    Posts:
    35
    Hi, Is there other way to edit animation clips in Inspector other than drop down list?
    Now, when I have 250+ clips, then I have to tediously and slowly wait for the list to scroll down and reveal that one animation I'm looking for? Any ideas? Thanks

    anim_list.jpg
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,485
    I can think of a few (S***ty) workarounds:
    • Pressing a letter key might jump you through the list to the first entry starting with that letter.
    • Make a separate Animator Controller to just put in the clips you want to edit. Or make a script that implements IAnimationClipSource so you can just throw them all in an array instead of needing to make lots of states and stuff.
    • It would probably be possible to do some editor scripting using reflection to access the animation window so you can make a better interface for it, but that would take a bunch of effort.
     
    ptm_oo likes this.
  3. ptm_oo

    ptm_oo

    Joined:
    Oct 30, 2014
    Posts:
    35
    Thanks for the ideas!
    1/ unfortunetly won't work
    2/ that's interesting idea, thanks I'll explore this
    3/ oh no, but it would be perfect
     
  4. faltek

    faltek

    Joined:
    Feb 2, 2021
    Posts:
    4
    Can resonate with this issue. It is brutal to find your callback function. Should have forward search matching.
     
  5. pioj

    pioj

    Joined:
    Nov 5, 2012
    Posts:
    30
    Wat about having a nice tool with a tree-like controls, like the new Input System has?
     
  6. WorldTravelerMatthieu

    WorldTravelerMatthieu

    Joined:
    Jul 22, 2022
    Posts:
    1
    Is there any asset that can help improve this inspector ? I have the same problem working on a pixel Art game and with all direction you have few hundreds animations to look into ... Even just a scroll option would help a bit :p
     
  7. ululbulul

    ululbulul

    Joined:
    May 31, 2019
    Posts:
    1
    I managed to create a custom editor window with buttons to select animation clips.
    For my project, all I needed was:
    1 get currently selected AnimatorController
    2 get the path of folder where controller is
    3 get all AnimationClips from that folder
    4 display all in window

    Below are my code snippets for inspiration

    (1 - 3)
    Code (CSharp):
    1. public static AnimationClip[] GetAllMotionsForController()
    2.                 {
    3.                         AnimatorController controller = GetCurrentController();
    4.                         GetControllerInfo(controller, out string controllerPath, out string controllerFolder, out string controllerName);
    5.                         return GetAllInstances<AnimationClip>(controllerFolder);
    6.                 }
    (1)
    Code (CSharp):
    1. public static AnimatorController GetCurrentController()
    2.                 {
    3.                         AnimatorController controller = null;
    4.                         EditorWindow[] tools = Resources.FindObjectsOfTypeAll<EditorWindow>();
    5.                         int i;
    6.                         int count = tools.Length;
    7.                         for (i = 0; i < count; i++)
    8.                         {
    9.                                 var toolType = tools[i].GetType();
    10.                                 var controllerProperty = toolType.GetProperty("animatorController", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
    11.                                 if (controllerProperty != null)
    12.                                 {
    13.                                         controller = controllerProperty.GetValue(tools[i], null) as AnimatorController;
    14.                                         return controller;
    15.                                 }
    16.                         }
    17.                         return null;
    18.                 }
    (2)
    Code (CSharp):
    1. public static void GetControllerInfo(AnimatorController controller,
    2.                         out string controllerPath, out string controllerFolder, out string controllerName)
    3.                 {
    4.                         controllerPath = AssetDatabase.GetAssetPath(controller);
    5.                         controllerFolder = controllerPath.Substring(0, controllerPath.LastIndexOf('/'));
    6.                         int controllerFullNameStart = controllerPath.LastIndexOf('/') + 1;
    7.                         int controllerFullNameEnd = controllerPath.LastIndexOf('.');
    8.                         string controllerFullName = controllerPath.Substring(controllerFullNameStart, controllerFullNameEnd - controllerFullNameStart);
    9.                         controllerName = controllerFullName.Split("__")[0];
    10.                 }
    (3)
    Code (CSharp):
    1. public static T[] GetAllInstances<T>(string parentFolder) where T : UnityEngine.Object
    2.                 {
    3.                         string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name, new[] { parentFolder });
    4.                         T[] a = new T[guids.Length];
    5.                         for (int i = 0; i < guids.Length; i++)
    6.                         {
    7.                                 string path = AssetDatabase.GUIDToAssetPath(guids[i]);
    8.                                 a[i] = AssetDatabase.LoadAssetAtPath<T>(path);
    9.                         }
    10.                         return a;
    11.                 }
    (4)
    Code (CSharp):
    1. AnimationWindow animWin = EditorWindow.GetWindow<AnimationWindow>(false, "Animation", false);
    2.                         AnimationClip[] motions = GlobalMethod.GetAllMotionsForController();
    3.                         int count = motions.Length;
    4.                         int i;
    5.                         for (i = 0; i < count; i++)
    6.                         {
    7.                                 if (PEGui.Button(motions[i].name, PELayout.V0, m_displayWidth, 18f))
    8.                                         animWin.animationClip = motions[i];
    9.                         }
     
  8. marshray48

    marshray48

    Joined:
    Sep 15, 2023
    Posts:
    3
    Following for the updates