DefaultValueAttribute.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //
  2. using System;
  3. namespace Animancer
  4. {
  5. /// <summary>[Editor-Conditional] Specifies the default value of a field and a secondary fallback.</summary>
  6. /// https://kybernetik.com.au/animancer/api/Animancer/DefaultValueAttribute
  7. [AttributeUsage(AttributeTargets.Field)]
  8. [System.Diagnostics.Conditional(Strings.UnityEditor)]
  9. public class DefaultValueAttribute : Attribute
  10. {
  11. /************************************************************************************************************************/
  12. /// <summary>The main default value.</summary>
  13. public virtual object Primary { get; protected set; }
  14. /************************************************************************************************************************/
  15. /// <summary>The fallback value to use if the target value was already equal to the <see cref="Primary"/>.</summary>
  16. public virtual object Secondary { get; protected set; }
  17. /************************************************************************************************************************/
  18. /// <summary>Creates a new <see cref="DefaultValueAttribute"/>.</summary>
  19. public DefaultValueAttribute(object primary, object secondary = null)
  20. {
  21. Primary = primary;
  22. Secondary = secondary;
  23. }
  24. /************************************************************************************************************************/
  25. /// <summary>Creates a new <see cref="DefaultValueAttribute"/>.</summary>
  26. protected DefaultValueAttribute() { }
  27. /************************************************************************************************************************/
  28. }
  29. }