Created
June 14, 2022 03:14
-
-
Save mousedoc/4b026b22a99076872c5d8c2ef8d946ea to your computer and use it in GitHub Desktop.
Unity Legacy Animation Creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using UnityEditor; | |
using UnityEngine; | |
public class LegacyAnimationCreator | |
{ | |
[MenuItem("Assets/Create/Legacy Animation", priority = 402)] | |
public static void CompressSelectedAnimationClips() | |
{ | |
var clip = new AnimationClip(); | |
clip.legacy = true; | |
clip.name = "New Legacy Animation"; | |
string path; | |
var selection = Selection.activeObject; | |
if (selection == null) | |
path = "Assets"; | |
else | |
path = AssetDatabase.GetAssetPath(selection.GetInstanceID()); | |
path = Path.GetDirectoryName(path); | |
path += $"/{clip.name}.anim"; | |
ProjectWindowUtil.CreateAsset(clip, path); | |
Selection.activeObject = clip; | |
EditorUtility.SetDirty(clip); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment