summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-06-30 13:41:45 +0200
committerGitHub <noreply@github.com>2019-06-30 13:41:45 +0200
commit82604195b4c2c80777f7ecaa547194c6a208e8cf (patch)
tree4aaab645c6f9458cd78f0625435b1276e92a581e /scene
parent96d3270c344c7fe9a463b87006b0c56004128f6d (diff)
parentd29b1b791774f0aa72a1230087c884b83e65d780 (diff)
Merge pull request #30062 from zaksnet/fix-referencerect-node
Adds ReferenceRect an option to be visible inside the game
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/reference_rect.cpp21
-rw-r--r--scene/gui/reference_rect.h6
2 files changed, 23 insertions, 4 deletions
diff --git a/scene/gui/reference_rect.cpp b/scene/gui/reference_rect.cpp
index 553e133946..052c8ccd05 100644
--- a/scene/gui/reference_rect.cpp
+++ b/scene/gui/reference_rect.cpp
@@ -38,26 +38,41 @@ void ReferenceRect::_notification(int p_what) {
if (!is_inside_tree())
return;
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint() || !editor_only)
draw_rect(Rect2(Point2(), get_size()), border_color, false);
}
}
-void ReferenceRect::set_border_color(const Color &color) {
- border_color = color;
+void ReferenceRect::set_border_color(const Color &p_color) {
+ border_color = p_color;
+ update();
}
Color ReferenceRect::get_border_color() const {
return border_color;
}
+void ReferenceRect::set_editor_only(const bool &p_enabled) {
+ editor_only = p_enabled;
+ update();
+}
+
+bool ReferenceRect::get_editor_only() const {
+ return editor_only;
+}
+
void ReferenceRect::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_border_color"), &ReferenceRect::get_border_color);
ClassDB::bind_method(D_METHOD("set_border_color", "color"), &ReferenceRect::set_border_color);
+ ClassDB::bind_method(D_METHOD("get_editor_only"), &ReferenceRect::get_editor_only);
+ ClassDB::bind_method(D_METHOD("set_editor_only", "enabled"), &ReferenceRect::set_editor_only);
+
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "border_color"), "set_border_color", "get_border_color");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "get_editor_only");
}
ReferenceRect::ReferenceRect() {
border_color = Color(1, 0, 0);
+ editor_only = true;
}
diff --git a/scene/gui/reference_rect.h b/scene/gui/reference_rect.h
index de3ccaeeca..7a88333cf2 100644
--- a/scene/gui/reference_rect.h
+++ b/scene/gui/reference_rect.h
@@ -37,6 +37,7 @@ class ReferenceRect : public Control {
GDCLASS(ReferenceRect, Control);
Color border_color;
+ bool editor_only;
protected:
void _notification(int p_what);
@@ -45,8 +46,11 @@ protected:
public:
ReferenceRect();
- void set_border_color(const Color &color);
+ void set_border_color(const Color &p_color);
Color get_border_color() const;
+
+ void set_editor_only(const bool &p_enabled);
+ bool get_editor_only() const;
};
#endif // REFERENCE_RECT_H