public static NullableInt ToNullableInt(this SerializedProperty sp) { var nullableInt = new NullableInt(); if (sp != null) { nullableInt.hasValue = true; nullableInt.value = sp.intValue; } return(nullableInt); }
public static void SetSerializedProperty(this SerializedProperty sp, NullableInt nullableInt) { if (sp == null || nullableInt.hasValue == false) { return; } if (sp.propertyType != SerializedPropertyType.Integer) { return; } sp.serializedObject.Update(); sp.intValue = nullableInt.value; sp.serializedObject.ApplyModifiedProperties(); }