summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorJosh Jones <kilauea.jones@gmail.com>2022-12-17 20:07:10 -0800
committerRémi Verschelde <rverschelde@gmail.com>2022-12-20 09:57:54 +0100
commit0572346985eef45123a0f25cbd7c295e06bd9097 (patch)
treebb053e7eed7479507721b8d85c845ed44666808c /scene/2d
parent0bb94df247a0a0c22333e2e99744fc3fd184601a (diff)
Fix typo and ensure backwards compatibility for changed property names
Changes to the name of the `navmesh` and `navpoly` properties on `NavigationRegion` caused navigation data to be lost on load. This PR creates uses `_set`/`_get` to handle compatibility with the older names on load, preserving the data. Also fixes a typo on `get_vertices_per_polygon` in `NavigationMesh`, and renames the property to remove the `polygon_` prefix which doesn't match the setter/getter. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/navigation_region_2d.cpp19
-rw-r--r--scene/2d/navigation_region_2d.h5
2 files changed, 24 insertions, 0 deletions
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index e030628110..675ef7c780 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -309,6 +309,25 @@ void NavigationRegion2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "travel_cost"), "set_travel_cost", "get_travel_cost");
}
+#ifndef DISABLE_DEPRECATED
+// Compatibility with earlier 4.0 betas.
+bool NavigationRegion2D::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "navpoly") {
+ set_navigation_polygon(p_value);
+ return true;
+ }
+ return false;
+}
+
+bool NavigationRegion2D::_get(const StringName &p_name, Variant &r_ret) const {
+ if (p_name == "navpoly") {
+ r_ret = get_navigation_polygon();
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
NavigationRegion2D::NavigationRegion2D() {
set_notify_transform(true);
diff --git a/scene/2d/navigation_region_2d.h b/scene/2d/navigation_region_2d.h
index 216e6088bc..45029fd95f 100644
--- a/scene/2d/navigation_region_2d.h
+++ b/scene/2d/navigation_region_2d.h
@@ -50,6 +50,11 @@ protected:
void _notification(int p_what);
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+#endif // DISABLE_DEPRECATED
+
public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const override;