Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace XCharts.Runtime
  4. {
  5. public static class PropertyUtil
  6. {
  7. public static bool SetColor(ref Color currentValue, Color newValue)
  8. {
  9. if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
  10. return false;
  11. currentValue = newValue;
  12. return true;
  13. }
  14. public static bool SetColor(ref Color32 currentValue, Color32 newValue)
  15. {
  16. if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
  17. return false;
  18. currentValue = newValue;
  19. return true;
  20. }
  21. public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct
  22. {
  23. if (EqualityComparer<T>.Default.Equals(currentValue, newValue))
  24. return false;
  25. currentValue = newValue;
  26. return true;
  27. }
  28. public static bool SetClass<T>(ref T currentValue, T newValue, bool notNull = false) where T : class
  29. {
  30. if (notNull)
  31. {
  32. if (newValue == null)
  33. {
  34. Debug.LogError("can not be null.");
  35. return false;
  36. }
  37. }
  38. if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
  39. return false;
  40. currentValue = newValue;
  41. return true;
  42. }
  43. }
  44. }