ShowIf.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using UnityEngine;
  3. namespace HQFPSWeapons
  4. {
  5. [AttributeUsage(AttributeTargets.Field)]
  6. public class ShowIf : PropertyAttribute
  7. {
  8. public readonly string m_PropertyName;
  9. public readonly float m_Indentation;
  10. public readonly bool m_RequiredBool = false;
  11. public readonly int m_RequiredInt = -1;
  12. public readonly float m_RequiredFloat = -1f;
  13. public readonly string m_RequiredString = "s";
  14. public readonly Vector3 m_RequiredVector3 = new Vector3(1, 1, 1);
  15. public ShowIf(string propertyName, bool requiredValue, float indentation = 16)
  16. {
  17. m_PropertyName = propertyName;
  18. m_RequiredBool = requiredValue;
  19. m_Indentation = indentation;
  20. }
  21. public ShowIf(string propertyName, int requiredValue, float indentation = 16)
  22. {
  23. m_PropertyName = propertyName;
  24. m_RequiredInt = requiredValue;
  25. m_Indentation = indentation;
  26. }
  27. public ShowIf(string propertyName, float requiredValue, float indentation = 16)
  28. {
  29. m_PropertyName = propertyName;
  30. m_RequiredFloat = requiredValue;
  31. m_Indentation = indentation;
  32. }
  33. public ShowIf(string propertyName, string requiredValue, float indentation = 16)
  34. {
  35. m_PropertyName = propertyName;
  36. m_RequiredString = requiredValue;
  37. m_Indentation = indentation;
  38. }
  39. public ShowIf(string propertyName, Vector3 requiredValue, float indentation = 16)
  40. {
  41. m_PropertyName = propertyName;
  42. m_RequiredVector3 = requiredValue;
  43. m_Indentation = indentation;
  44. }
  45. }
  46. }