If you just want to allow a user to modify the value, you can use the generic PropertyField() to automatically use the editor's default representation for whatever field type it happens to be:
EditorGUI.PropertyField(dirRect, waveOrigin, new GUIContent("Point of Origin"));
But if you want to extract the value they set and read / modify it, then it would be useful to give yourself a couple helper methods:
public static class SerializedPropertyExtensions {
public static Vector2 GetFloat2AsVector(this SerializedProperty property) {
Vector2 output;
var p = property.Copy();
p.Next(true);
output.x = p.floatValue;
p.Next(true);
output.y = p.floatValue;
return output;
}
public static void SetFloat2FromVector(this SerializedProperty property, Vector2 value) {
var p = property.Copy();
p.Next(true);
p.floatValue = value.x;
p.Next(true);
p.floatValue = value.y;
}
}
Then you can work with the Vector2Field as you were trying to do:
var v = waveOrigin.GetFloat2AsVector();
v = EditorGUI.Vector2Field(dirRect, "Point of Origin", v);
waveOrigin.SetFloat2FromVector(v);
Don't forget to call serializedObject.ApplyModifiedProperties() to commit the changes the user's made to the object's data.
Vector2from the Unity core API andfloat2from the Mathematics package are not the same thing? \$\endgroup\$