Merge pull request #59916 from KoBeWi/gimzo_extends
This commit is contained in:
commit
9caba19095
4 changed files with 13 additions and 17 deletions
|
@ -732,7 +732,7 @@
|
|||
The override to the default [MultiplayerAPI]. Set to [code]null[/code] to use the default [SceneTree] one.
|
||||
</member>
|
||||
<member name="editor_description" type="String" setter="set_editor_description" getter="get_editor_description" default="""">
|
||||
Add a custom description to a node.
|
||||
Add a custom description to a node. It will be displayed in a tooltip when hovered in editor's scene tree.
|
||||
</member>
|
||||
<member name="multiplayer" type="MultiplayerAPI" setter="" getter="get_multiplayer">
|
||||
The [MultiplayerAPI] instance associated with this node. Either the [member custom_multiplayer], or the default SceneTree one (if inside tree).
|
||||
|
|
|
@ -8,4 +8,9 @@
|
|||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="gizmo_extents" type="float" setter="set_gizmo_extents" getter="get_gizmo_extents" default="10.0">
|
||||
Size of the gizmo cross that appears in the editor.
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#include "position_2d.h"
|
||||
|
||||
const real_t DEFAULT_GIZMO_EXTENTS = 10.0;
|
||||
|
||||
void Position2D::_draw_cross() {
|
||||
const real_t extents = get_gizmo_extents();
|
||||
|
||||
|
@ -103,28 +101,19 @@ void Position2D::_notification(int p_what) {
|
|||
}
|
||||
|
||||
void Position2D::set_gizmo_extents(real_t p_extents) {
|
||||
if (p_extents == DEFAULT_GIZMO_EXTENTS) {
|
||||
set_meta("_gizmo_extents_", Variant());
|
||||
} else {
|
||||
set_meta("_gizmo_extents_", p_extents);
|
||||
}
|
||||
|
||||
gizmo_extents = p_extents;
|
||||
update();
|
||||
}
|
||||
|
||||
real_t Position2D::get_gizmo_extents() const {
|
||||
if (has_meta("_gizmo_extents_")) {
|
||||
return get_meta("_gizmo_extents_");
|
||||
} else {
|
||||
return DEFAULT_GIZMO_EXTENTS;
|
||||
}
|
||||
return gizmo_extents;
|
||||
}
|
||||
|
||||
void Position2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_set_gizmo_extents", "extents"), &Position2D::set_gizmo_extents);
|
||||
ClassDB::bind_method(D_METHOD("_get_gizmo_extents"), &Position2D::get_gizmo_extents);
|
||||
ClassDB::bind_method(D_METHOD("set_gizmo_extents", "extents"), &Position2D::set_gizmo_extents);
|
||||
ClassDB::bind_method(D_METHOD("get_gizmo_extents"), &Position2D::get_gizmo_extents);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gizmo_extents", PROPERTY_HINT_RANGE, "0,1000,0.1,or_greater", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_gizmo_extents", "_get_gizmo_extents");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gizmo_extents", PROPERTY_HINT_RANGE, "0,1000,0.1,or_greater"), "set_gizmo_extents", "get_gizmo_extents");
|
||||
}
|
||||
|
||||
Position2D::Position2D() {
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
class Position2D : public Node2D {
|
||||
GDCLASS(Position2D, Node2D);
|
||||
|
||||
real_t gizmo_extents = 10.0;
|
||||
|
||||
void _draw_cross();
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue