Tanoda
SetPropertyUtility.cs
Go to the documentation of this file.
1
6{
7 internal static class SetPropertyUtility
8 {
9 public static bool SetColor(ref Color currentValue, Color newValue)
10 {
11 if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
12 return false;
13
14 currentValue = newValue;
15 return true;
16 }
17
18 public static bool SetStruct<T>(ref T currentValue, T newValue) where T: struct
19 {
20 if (currentValue.Equals(newValue))
21 return false;
22
23 currentValue = newValue;
24 return true;
25 }
26
27 public static bool SetClass<T>(ref T currentValue, T newValue) where T: class
28 {
29 if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
30 return false;
31
32 currentValue = newValue;
33 return true;
34 }
35 }
36}
UnityEngine.Color Color
Definition: TestScript.cs:32
Credit Erdener Gonenc - @PixelEnvision.