5 namespace droid.Runtime.Utilities.ScriptableObjects.SerialisableDictionary {
8 public static class SerializedPropertyExtension {
9 public static int GetObjectCode(
this SerializedProperty p) {
11 return p.propertyPath.GetHashCode() ^ p.serializedObject.GetHashCode();
14 public static bool EqualBasics(SerializedProperty left, SerializedProperty right) {
15 if (left.propertyType != right.propertyType) {
19 if (left.propertyType == SerializedPropertyType.Integer) {
20 if (left.type == right.type) {
21 if (left.type ==
"int") {
22 return left.intValue == right.intValue;
25 return left.longValue == right.longValue;
31 if (left.propertyType == SerializedPropertyType.String) {
32 return left.stringValue == right.stringValue;
35 if (left.propertyType == SerializedPropertyType.ObjectReference) {
36 return left.objectReferenceValue == right.objectReferenceValue;
39 if (left.propertyType == SerializedPropertyType.Enum) {
40 return left.enumValueIndex == right.enumValueIndex;
43 if (left.propertyType == SerializedPropertyType.Boolean) {
44 return left.boolValue == right.boolValue;
47 if (left.propertyType == SerializedPropertyType.Float) {
48 if (left.type == right.type) {
49 if (left.type ==
"float") {
50 return Math.Abs(left.floatValue - right.floatValue) <
double.Epsilon;
53 return Math.Abs(left.doubleValue - right.doubleValue) <
double.Epsilon;
59 if (left.propertyType == SerializedPropertyType.Color) {
60 return left.colorValue == right.colorValue;
63 if (left.propertyType == SerializedPropertyType.LayerMask) {
64 return left.intValue == right.intValue;
67 if (left.propertyType == SerializedPropertyType.Vector2) {
68 return left.vector2Value == right.vector2Value;
71 if (left.propertyType == SerializedPropertyType.Vector3) {
72 return left.vector3Value == right.vector3Value;
75 if (left.propertyType == SerializedPropertyType.Vector4) {
76 return left.vector4Value == right.vector4Value;
79 if (left.propertyType == SerializedPropertyType.Rect) {
80 return left.rectValue == right.rectValue;
83 if (left.propertyType == SerializedPropertyType.ArraySize) {
84 return left.arraySize == right.arraySize;
87 if (left.propertyType == SerializedPropertyType.Character) {
88 return left.intValue == right.intValue;
91 if (left.propertyType == SerializedPropertyType.AnimationCurve) {
95 if (left.propertyType == SerializedPropertyType.Bounds) {
96 return left.boundsValue == right.boundsValue;
99 if (left.propertyType == SerializedPropertyType.Gradient) {
103 if (left.propertyType == SerializedPropertyType.Quaternion) {
104 return left.quaternionValue == right.quaternionValue;
110 public static void CopyBasics(SerializedProperty source, SerializedProperty target) {
111 if (source.propertyType != target.propertyType) {
115 if (source.propertyType == SerializedPropertyType.Integer) {
116 if (source.type == target.type) {
117 if (source.type ==
"int") {
118 target.intValue = source.intValue;
120 target.longValue = source.longValue;
123 }
else if (source.propertyType == SerializedPropertyType.String) {
124 target.stringValue = source.stringValue;
125 }
else if (source.propertyType == SerializedPropertyType.ObjectReference) {
126 target.objectReferenceValue = source.objectReferenceValue;
127 }
else if (source.propertyType == SerializedPropertyType.Enum) {
128 target.enumValueIndex = source.enumValueIndex;
129 }
else if (source.propertyType == SerializedPropertyType.Boolean) {
130 target.boolValue = source.boolValue;
131 }
else if (source.propertyType == SerializedPropertyType.Float) {
132 if (source.type == target.type) {
133 if (source.type ==
"float") {
134 target.floatValue = source.floatValue;
136 target.doubleValue = source.doubleValue;
139 }
else if (source.propertyType == SerializedPropertyType.Color) {
140 target.colorValue = source.colorValue;
141 }
else if (source.propertyType == SerializedPropertyType.LayerMask) {
142 target.intValue = source.intValue;
143 }
else if (source.propertyType == SerializedPropertyType.Vector2) {
144 target.vector2Value = source.vector2Value;
145 }
else if (source.propertyType == SerializedPropertyType.Vector3) {
146 target.vector3Value = source.vector3Value;
147 }
else if (source.propertyType == SerializedPropertyType.Vector4) {
148 target.vector4Value = source.vector4Value;
149 }
else if (source.propertyType == SerializedPropertyType.Rect) {
150 target.rectValue = source.rectValue;
151 }
else if (source.propertyType == SerializedPropertyType.ArraySize) {
152 target.arraySize = source.arraySize;
153 }
else if (source.propertyType == SerializedPropertyType.Character) {
154 target.intValue = source.intValue;
155 }
else if (source.propertyType == SerializedPropertyType.AnimationCurve) {
156 target.animationCurveValue = source.animationCurveValue;
157 }
else if (source.propertyType == SerializedPropertyType.Bounds) {
158 target.boundsValue = source.boundsValue;
159 }
else if (source.propertyType == SerializedPropertyType.Gradient) {
161 }
else if (source.propertyType == SerializedPropertyType.Quaternion) {
162 target.quaternionValue = source.quaternionValue;
164 if (source.hasChildren && target.hasChildren) {
165 var source_iterator = source.Copy();
166 var target_iterator = target.Copy();
168 if (source_iterator.propertyType == SerializedPropertyType.Generic) {
169 if (!source_iterator.Next(
true) || !target_iterator.Next(
true)) {
172 }
else if (!source_iterator.Next(
false) || !target_iterator.Next(
false)) {
176 CopyBasics(source_iterator, target_iterator);