MixerState.Drawer.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2022 Kybernetik //
  2. #pragma warning disable CS0649 // Field is never assigned to, and will always have its default value.
  3. using System;
  4. namespace Animancer
  5. {
  6. /// https://kybernetik.com.au/animancer/api/Animancer/MixerState
  7. partial class MixerState
  8. {
  9. /************************************************************************************************************************/
  10. /// <summary>The number of parameters being managed by this state.</summary>
  11. protected virtual int ParameterCount => 0;
  12. /// <summary>Returns the name of a parameter being managed by this state.</summary>
  13. /// <exception cref="NotSupportedException">This state doesn't manage any parameters.</exception>
  14. protected virtual string GetParameterName(int index) => throw new NotSupportedException();
  15. /// <summary>Returns the type of a parameter being managed by this state.</summary>
  16. /// <exception cref="NotSupportedException">This state doesn't manage any parameters.</exception>
  17. protected virtual UnityEngine.AnimatorControllerParameterType GetParameterType(int index) => throw new NotSupportedException();
  18. /// <summary>Returns the value of a parameter being managed by this state.</summary>
  19. /// <exception cref="NotSupportedException">This state doesn't manage any parameters.</exception>
  20. protected virtual object GetParameterValue(int index) => throw new NotSupportedException();
  21. /// <summary>Sets the value of a parameter being managed by this state.</summary>
  22. /// <exception cref="NotSupportedException">This state doesn't manage any parameters.</exception>
  23. protected virtual void SetParameterValue(int index, object value) => throw new NotSupportedException();
  24. /************************************************************************************************************************/
  25. #if UNITY_EDITOR
  26. /************************************************************************************************************************/
  27. /// <summary>[Editor-Only] Returns a <see cref="Drawer{T}"/> for this state.</summary>
  28. protected internal override Editor.IAnimancerNodeDrawer CreateDrawer() => new Drawer<MixerState>(this);
  29. /************************************************************************************************************************/
  30. /// <inheritdoc/>
  31. public class Drawer<T> : Editor.ParametizedAnimancerStateDrawer<T> where T : MixerState
  32. {
  33. /************************************************************************************************************************/
  34. /// <summary>Creates a new <see cref="Drawer{T}"/> to manage the Inspector GUI for the `state`.</summary>
  35. public Drawer(T state) : base(state) { }
  36. /************************************************************************************************************************/
  37. /// <inheritdoc/>
  38. public override int ParameterCount => Target.ParameterCount;
  39. /// <inheritdoc/>
  40. public override string GetParameterName(int index) => Target.GetParameterName(index);
  41. /// <inheritdoc/>
  42. public override UnityEngine.AnimatorControllerParameterType GetParameterType(int index) => Target.GetParameterType(index);
  43. /// <inheritdoc/>
  44. public override object GetParameterValue(int index) => Target.GetParameterValue(index);
  45. /// <inheritdoc/>
  46. public override void SetParameterValue(int index, object value) => Target.SetParameterValue(index, value);
  47. /************************************************************************************************************************/
  48. }
  49. /************************************************************************************************************************/
  50. #endif
  51. /************************************************************************************************************************/
  52. }
  53. }