Created
September 17, 2024 15:04
-
-
Save Petethegoat/09eb22cc6c79266b67a94fda414f631e to your computer and use it in GitHub Desktop.
Basic editor functions to copy events from one animation clip to another. No guarentee of functionality, please only use with backups or under source control.
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 UnityEngine; | |
using UnityEditor; | |
using UnityEditor.ShortcutManagement; | |
public static class AnimClipEventCopy | |
{ | |
static AnimationClip sourceClip; | |
[Shortcut("AnimClipEventCopy/Set Source Clip")] | |
public static void CopyEvents() | |
{ | |
if(Selection.objects.Length != 1) | |
{ | |
SceneView.lastActiveSceneView.ShowNotification(new("Select one animation clip to copy from.")); | |
return; | |
} | |
if(Selection.activeObject is AnimationClip clip) | |
{ | |
sourceClip = clip; | |
SceneView.lastActiveSceneView.ShowNotification(new($"Source clip set to: {clip.name}")); | |
} | |
} | |
[Shortcut("AnimClipEventCopy/Paste Events to Clip")] | |
public static void PasteEvents() | |
{ | |
if(sourceClip == null) | |
{ | |
SceneView.lastActiveSceneView.ShowNotification(new("No source clip to copy events from.")); | |
return; | |
} | |
if(Selection.objects.Length != 1) | |
{ | |
SceneView.lastActiveSceneView.ShowNotification(new("Select one animation clip to paste into.")); | |
return; | |
} | |
if(Selection.activeObject is AnimationClip clip) | |
{ | |
AnimationUtility.SetAnimationEvents(clip, sourceClip.events); | |
SceneView.lastActiveSceneView.ShowNotification(new($"Copied events from {sourceClip.name} to {clip.name}")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment