// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik // #if UNITY_EDITOR using UnityEngine; namespace Animancer.Editor { /// [Editor-Only] An object that can draw custom GUI elements relating to transitions. /// /// Implement this in a custom transition type to give it custom GUI elements. /// /// Example: /// using Animancer; /// using UnityEngine; /// /// // AttackTransition.cs contains your custom transition type. /// public partial class AttackTransition : ClipTransition /// { /// [SerializeField] private Bounds _HitBox; /// [SerializeField] private float _HitStartTime; /// [SerializeField] private float _HitEndTime; /// /// // Damage, Knockback, etc. /// } /// /// // AttackTransition.Drawer.cs contains the custom GUI for it. /// #if UNITY_EDITOR /// /// using Animancer.Editor; /// using UnityEditor; /// using UnityEngine; /// /// public partial class AttackTransition : ITransitionGUI /// { /// // See each method for an example. /// public void OnPreviewSceneGUI(TransitionPreviewDetails details) { } /// public void OnTimelineBackgroundGUI() { } /// public void OnTimelineForegroundGUI() { } /// } /// /// #endif /// /// https://kybernetik.com.au/animancer/api/Animancer.Editor/ITransitionGUI public interface ITransitionGUI { /************************************************************************************************************************/ /// Called while drawing the GUI for the scene. /// /// Example: /// // For the AttackTransition example from ITransitionGUI. /// // Draw the hit box as a wireframe cube. /// public void OnPreviewSceneGUI(TransitionPreviewDetails details) /// { /// Color color = Handles.color; /// Handles.color = new(0.5f, 1, 0.5f); /// /// Transform transform = details.Transform; /// /// Handles.DrawWireCube( /// transform.TransformPoint(_HitBox.center), /// _HitBox.size); /// /// Handles.color = color; /// } /// void OnPreviewSceneGUI(TransitionPreviewDetails details); /// /// Called while drawing the background GUI for the for the /// . /// /// /// Example: /// // For the AttackTransition example from ITransitionGUI. /// // Draw the hit time as a highlighted area. /// public void OnTimelineBackgroundGUI() /// { /// if (Event.current.type != EventType.Repaint) /// return; /// /// Color previousColor = GUI.color; /// TimelineGUI timelineGUI = TimelineGUI.Current; /// /// float start = timelineGUI.SecondsToPixels(_HitStartTime); /// float end = timelineGUI.SecondsToPixels(_HitEndTime); /// Rect area = new Rect( /// start, /// 0, /// end - start, /// timelineGUI.Area.height - timelineGUI.TickHeight); /// /// Color color = new Color(0.9f, 0.4f, 0.25f, 0.5f); /// /// EditorGUI.DrawRect(area, color); /// /// GUI.color = previousColor; /// } /// void OnTimelineBackgroundGUI(); /// /// Called while drawing the foreground GUI for the for the /// . /// /// /// This method can be used similarly to the example, /// except that it draws in front of everything else. /// void OnTimelineForegroundGUI(); /************************************************************************************************************************/ } /// [Editor-Only] Details about the current preview used by . /// https://kybernetik.com.au/animancer/api/Animancer.Editor/TransitionPreviewDetails public readonly struct TransitionPreviewDetails { /************************************************************************************************************************/ /// The used to play the preview. public readonly AnimancerGraph Animancer; /// The of the used to play the preview. public Transform Transform => Animancer.Component.Animator.transform; /************************************************************************************************************************/ /// Creates a new . public TransitionPreviewDetails(AnimancerGraph animancer) { Animancer = animancer; } /************************************************************************************************************************/ } } #endif