From e7dfbec8e8634e767d78959941daf71a96e021cf Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Apr 2021 19:10:30 +0800 Subject: =?UTF-8?q?*=E7=A7=BB=E5=8A=A8=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/Core/Utility/SetPropertyUtility.cs | 36 ++++++++++++++++++++++ .../UI/Core/Utility/SetPropertyUtility.cs.meta | 11 +++++++ 2 files changed, 47 insertions(+) create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/SetPropertyUtility.cs create mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/SetPropertyUtility.cs.meta (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility') diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/SetPropertyUtility.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/SetPropertyUtility.cs new file mode 100644 index 0000000..15d8519 --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/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; + } + } +} diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/SetPropertyUtility.cs.meta b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/SetPropertyUtility.cs.meta new file mode 100644 index 0000000..ee3936e --- /dev/null +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/SetPropertyUtility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7eb311d761ee3d409de0593312d6fa2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.1-26-g67d0