diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2021-06-16 23:23:52 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2021-06-17 17:10:52 -0400 |
commit | 1a9e6cba2f4b2a7bf43e0b1b03ea27af66a45b1f (patch) | |
tree | b2172129d36d9e149f6cf88c04c2edabf53f6037 /scene/resources/rectangle_shape_2d.cpp | |
parent | 13c4796693c3c32993cd49b226fc9c78ad376f6d (diff) | |
download | redot-engine-1a9e6cba2f4b2a7bf43e0b1b03ea27af66a45b1f.tar.gz |
Re-add extents property to box shapes for compatibility
Diffstat (limited to 'scene/resources/rectangle_shape_2d.cpp')
-rw-r--r-- | scene/resources/rectangle_shape_2d.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp index dc4c6dc2d7..17ce0b34ac 100644 --- a/scene/resources/rectangle_shape_2d.cpp +++ b/scene/resources/rectangle_shape_2d.cpp @@ -37,6 +37,26 @@ void RectangleShape2D::_update_shape() { emit_changed(); } +#ifndef DISABLE_DEPRECATED +bool RectangleShape2D::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "extents") { // Compatibility with Godot 3.x. + // Convert to `size`, twice as big. + set_size((Vector2)p_value * 2); + return true; + } + return false; +} + +bool RectangleShape2D::_get(const StringName &p_name, Variant &r_property) const { + if (p_name == "extents") { // Compatibility with Godot 3.x. + // Convert to `extents`, half as big. + r_property = size / 2; + return true; + } + return false; +} +#endif // DISABLE_DEPRECATED + void RectangleShape2D::set_size(const Vector2 &p_size) { size = p_size; _update_shape(); |