From 00dae1bd426d892dff73a50f1c505afd1ac00a90 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 8 Oct 2020 09:50:33 +0800 Subject: +init --- .../UnityEngine.UI/UI/Core/SetPropertyUtility.cs | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SetPropertyUtility.cs (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SetPropertyUtility.cs') diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SetPropertyUtility.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SetPropertyUtility.cs new file mode 100644 index 0000000..15d8519 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SetPropertyUtility.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using UnityEngine.Events; + +namespace UnityEngine.UI +{ + internal static class SetPropertyUtility + { + public static bool SetColor(ref Color currentValue, Color newValue) + { + if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a) + return false; + + currentValue = newValue; + return true; + } + + public static bool SetStruct(ref T currentValue, T newValue) where T : struct + { + if (EqualityComparer.Default.Equals(currentValue, newValue)) + return false; + + currentValue = newValue; + return true; + } + + public static bool SetClass(ref T currentValue, T newValue) where T : class + { + if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue))) + return false; + + currentValue = newValue; + return true; + } + } +} -- cgit v1.1-26-g67d0