Skip to content

Instantly share code, notes, and snippets.

@mousedoc
Created June 14, 2022 03:14
Show Gist options
  • Save mousedoc/4b026b22a99076872c5d8c2ef8d946ea to your computer and use it in GitHub Desktop.
Save mousedoc/4b026b22a99076872c5d8c2ef8d946ea to your computer and use it in GitHub Desktop.
Unity Legacy Animation Creator
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