BasicCustomGUI.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //
  2. #if UNITY_EDITOR
  3. using UnityEditor;
  4. using UnityEngine;
  5. namespace Animancer.Editor
  6. {
  7. /// <summary>[Editor-Only] A <see cref="ICustomGUI"/> for <see cref="float"/>.</summary>
  8. /// https://kybernetik.com.au/animancer/api/Animancer.Editor/FloatGUI
  9. ///
  10. [CustomGUI(typeof(float))]
  11. public class FloatGUI : CustomGUI<float>
  12. {
  13. /************************************************************************************************************************/
  14. /// <inheritdoc/>
  15. public override void DoGUI()
  16. => Value = EditorGUILayout.FloatField(Label, Value);
  17. /************************************************************************************************************************/
  18. }
  19. /// <summary>[Editor-Only] A <see cref="ICustomGUI"/> for <see cref="int"/>.</summary>
  20. /// https://kybernetik.com.au/animancer/api/Animancer.Editor/IntGUI
  21. ///
  22. [CustomGUI(typeof(int))]
  23. public class IntGUI : CustomGUI<int>
  24. {
  25. /************************************************************************************************************************/
  26. /// <inheritdoc/>
  27. public override void DoGUI()
  28. => Value = EditorGUILayout.IntField(Label, Value);
  29. /************************************************************************************************************************/
  30. }
  31. /// <summary>[Editor-Only] A <see cref="ICustomGUI"/> for <see cref="string"/>.</summary>
  32. /// https://kybernetik.com.au/animancer/api/Animancer.Editor/StringGUI
  33. ///
  34. [CustomGUI(typeof(string))]
  35. public class StringGUI : CustomGUI<string>
  36. {
  37. /************************************************************************************************************************/
  38. /// <inheritdoc/>
  39. public override void DoGUI()
  40. => Value = EditorGUILayout.TextField(Label, Value);
  41. /************************************************************************************************************************/
  42. }
  43. /// <summary>[Editor-Only] A <see cref="ICustomGUI"/> for <see cref="Object"/>.</summary>
  44. /// https://kybernetik.com.au/animancer/api/Animancer.Editor/ObjectGUI_1
  45. ///
  46. [CustomGUI(typeof(Object))]
  47. public class ObjectGUI<T> : CustomGUI<T>
  48. where T : Object
  49. {
  50. /************************************************************************************************************************/
  51. /// <inheritdoc/>
  52. public override void DoGUI()
  53. => Value = AnimancerGUI.DoObjectFieldGUI(Label, Value, true);
  54. /************************************************************************************************************************/
  55. }
  56. }
  57. #endif