源战役客户端
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.

31 lines
885 B

  1. using UnityEngine;
  2. internal static class SetPropertyUtilityExt
  3. {
  4. public static bool SetColor(ref Color currentValue, Color newValue)
  5. {
  6. if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
  7. return false;
  8. currentValue = newValue;
  9. return true;
  10. }
  11. public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct
  12. {
  13. if (currentValue.Equals(newValue))
  14. return false;
  15. currentValue = newValue;
  16. return true;
  17. }
  18. public static bool SetClass<T>(ref T currentValue, T newValue) where T : class
  19. {
  20. if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
  21. return false;
  22. currentValue = newValue;
  23. return true;
  24. }
  25. }