diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-03-15 08:57:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-15 08:57:45 +0100 |
commit | 6eef187a81cbdd3cd314776de372e753f79f9831 (patch) | |
tree | 2f57c757cab8a090efd9b9b6f6daebce3b2a080f | |
parent | d1b5c1d09f43e423b92a083ff5e3dd4d4d81cbcb (diff) | |
parent | b80406770ff0fe108395354121e03743a8a7121e (diff) |
Merge pull request #46993 from gongpha/check-if-edit-called-via-editor
Check if _edit_set_position and _edit_set_rect was used outside an editor
-rw-r--r-- | scene/gui/control.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index d209b17fa1..c13bce5e0c 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -96,6 +96,7 @@ void Control::_edit_set_state(const Dictionary &p_state) { void Control::_edit_set_position(const Point2 &p_position) { #ifdef TOOLS_ENABLED + ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be used from editor plugins."); set_position(p_position, CanvasItemEditor::get_singleton()->is_anchors_mode_enabled() && Object::cast_to<Control>(data.parent)); #else // Unlikely to happen. TODO: enclose all _edit_ functions into TOOLS_ENABLED @@ -117,6 +118,7 @@ Size2 Control::_edit_get_scale() const { void Control::_edit_set_rect(const Rect2 &p_edit_rect) { #ifdef TOOLS_ENABLED + ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be used from editor plugins."); set_position((get_position() + get_transform().basis_xform(p_edit_rect.position)).snapped(Vector2(1, 1)), CanvasItemEditor::get_singleton()->is_anchors_mode_enabled()); set_size(p_edit_rect.size.snapped(Vector2(1, 1)), CanvasItemEditor::get_singleton()->is_anchors_mode_enabled()); #else |