// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2023 Kybernetik //
using UnityEngine;
namespace Animancer
{
/// An with some additional details (mainly for the Unity Editor GUI).
///
/// Documentation: Transitions
///
/// https://kybernetik.com.au/animancer/api/Animancer/ITransitionDetailed
///
public interface ITransitionDetailed : ITransition
{
/************************************************************************************************************************/
/// Can this transition create a valid ?
bool IsValid { get; }
/// What will the value of be for the created state?
bool IsLooping { get; }
/// The to start the animation at.
/// allows the animation to continue from its current time.
float NormalizedStartTime { get; set; }
/// The maximum amount of time the animation is expected to take (in seconds).
/// The actual duration can vary in states like .
float MaximumDuration { get; }
/// The to play the animation at.
float Speed { get; set; }
/************************************************************************************************************************/
}
/// https://kybernetik.com.au/animancer/api/Animancer/AnimancerUtilities
public static partial class AnimancerUtilities
{
/************************************************************************************************************************/
/// Returns the with support for .
public static bool IsValid(this ITransition transition)
{
if (transition == null)
return false;
if (TryGetWrappedObject(transition, out ITransitionDetailed detailed))
return detailed.IsValid;
return true;
}
/************************************************************************************************************************/
/// Outputs the or .
/// Returns false if the `motionOrTransition` is null or an unsupported type.
public static bool TryGetIsLooping(object motionOrTransition, out bool isLooping)
{
if (motionOrTransition is Motion motion)
{
isLooping = motion.isLooping;
return true;
}
else if (TryGetWrappedObject(motionOrTransition, out ITransitionDetailed transition))
{
isLooping = transition.IsLooping;
return true;
}
else
{
isLooping = false;
return false;
}
}
/************************************************************************************************************************/
/// Outputs the or .
/// Returns false if the `motionOrTransition` is null or an unsupported type.
public static bool TryGetLength(object motionOrTransition, out float length)
{
if (motionOrTransition is AnimationClip clip)
{
length = clip.length;
return true;
}
else if (TryGetWrappedObject(motionOrTransition, out ITransitionDetailed transition))
{
length = transition.MaximumDuration;
return true;
}
else
{
length = 0;
return false;
}
}
/************************************************************************************************************************/
}
}