Created
December 6, 2018 19:37
-
-
Save attilam/f9e6f15f780b48769bfd20716429c483 to your computer and use it in GitHub Desktop.
Create Legacy AnimationClips using the Asset Menu in Unity
This file contains 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 CreateLegacyAnimationClip { | |
[MenuItem("Assets/Create/Animation (Legacy)", false, 402)] | |
public static void CreateIt() | |
{ | |
AnimationClip clip = new AnimationClip(); | |
clip.legacy = true; | |
// via https://forum.unity.com/threads/how-to-get-currently-selected-folder-for-putting-new-asset-into.81359/ | |
string path = "Assets"; | |
foreach (UnityEngine.Object obj in Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets)) | |
{ | |
path = AssetDatabase.GetAssetPath(obj); | |
if (File.Exists(path)) | |
{ | |
path = Path.GetDirectoryName(path); | |
} | |
break; | |
} | |
AssetDatabase.CreateAsset(clip, path+"/New Legacy Animation.anim"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment