// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2023 Kybernetik //
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Animancer.FSM
{
/// [Editor-Only] Utilities used by the system.
///
/// Documentation: Finite State Machines
///
/// https://kybernetik.com.au/animancer/api/Animancer.FSM/StateMachineUtilities
///
public static class StateMachineUtilities
{
/************************************************************************************************************************/
/// Draws a GUI field for the `value`.
public static T DoGenericField(Rect area, string label, T value)
{
if (typeof(Object).IsAssignableFrom(typeof(T)))
{
return (T)(object)EditorGUI.ObjectField(
area, label, value as Object, typeof(T), true);
}
var stateName = value != null ? value.ToString() : "Null";
EditorGUI.LabelField(area, label, stateName);
return value;
}
/************************************************************************************************************************/
///
/// If the is positive, this method moves the by that amount and
/// adds the .
///
public static void NextVerticalArea(ref Rect area)
{
if (area.height > 0)
area.y += area.height + EditorGUIUtility.standardVerticalSpacing;
}
/************************************************************************************************************************/
}
}
#endif