Search Unity

How do you rename an animation clip?

Discussion in 'Animation' started by SwingNinja, Dec 17, 2018.

  1. SwingNinja

    SwingNinja

    Joined:
    Mar 13, 2017
    Posts:
    17
    By animation clip, I mean the one like the screenshot below. When I tried to duplicate the "Jump" clip, it just created a new file called "Jump 1" and didn't let me to rename it to something else.

    I sure can rename each file manually from Windows Explorer, but I am looking for something less painful than that (if possible).
     
  2. TeKniKo64

    TeKniKo64

    Joined:
    Oct 7, 2014
    Posts:
    30
    Open the animation. In the Inspector, above the Length/FPS. Click that and rename.
     
    beshr_11 likes this.
  3. roamerfree

    roamerfree

    Joined:
    Apr 2, 2022
    Posts:
    6
    Or you can find the animation clip in the asset folder under Project tab, and rename the clip by right-clicking it.
     
  4. JohnLoots

    JohnLoots

    Joined:
    Oct 28, 2023
    Posts:
    1
    Something i quickly whipped up to rename some animation clips

    Code (CSharp):
    1. void OnGUI(){
    2.             GUILayout.Label("Key");
    3.             key = GUILayout.TextField(key);
    4.  
    5.             GUILayout.Label("Value");
    6.             value = GUILayout.TextField(value);
    7.  
    8.             if (GUILayout.Button("Rename")){
    9.                 selectedObjects = Selection.objects;
    10.  
    11.                 AssetDatabase.StartAssetEditing();          
    12.                 foreach (var obj in selectedObjects)
    13.                 {
    14.                     var name = obj.name;
    15.                     var newName = name.Replace(key, value);
    16.                
    17.                     var path = AssetDatabase.GetAssetPath(obj);
    18.                     var newPath = path.Replace(name, newName);
    19.                
    20.                     AssetDatabase.MoveAsset(path, newPath);
    21.                 }
    22.                 AssetDatabase.StopAssetEditing();
    23.             }
    24.         }
     
    Last edited: Apr 21, 2024 at 9:54 AM