From 6b15b4f90469375ac388a73477356c90bd6e194d Mon Sep 17 00:00:00 2001 From: JFonS Date: Mon, 29 Oct 2018 11:30:28 +0100 Subject: [PATCH] Expose the new gizmo plugin system to scripting --- doc/classes/EditorPlugin.xml | 16 +++ doc/classes/EditorSpatialGizmoPlugin.xml | 175 +++++++++++++++++++++++ editor/editor_node.cpp | 1 + editor/editor_plugin.cpp | 10 ++ editor/editor_plugin.h | 4 + editor/plugins/path_editor_plugin.cpp | 2 +- editor/plugins/spatial_editor_plugin.cpp | 167 +++++++++++++++++---- editor/plugins/spatial_editor_plugin.h | 22 +-- modules/csg/csg_gizmos.cpp | 2 +- scene/3d/mesh_instance.cpp | 2 + scene/3d/spatial.cpp | 3 + 11 files changed, 364 insertions(+), 40 deletions(-) create mode 100644 doc/classes/EditorSpatialGizmoPlugin.xml diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index ac139f18c96..c85deaed681 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -110,6 +110,14 @@ + + + + + + + + @@ -394,6 +402,14 @@ + + + + + + + + diff --git a/doc/classes/EditorSpatialGizmoPlugin.xml b/doc/classes/EditorSpatialGizmoPlugin.xml new file mode 100644 index 00000000000..521ec748b3e --- /dev/null +++ b/doc/classes/EditorSpatialGizmoPlugin.xml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 930d8c5bad1..4c5068fcd92 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3091,6 +3091,7 @@ void EditorNode::register_editor_types() { ClassDB::register_class(); ClassDB::register_virtual_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_virtual_class(); ClassDB::register_class(); ClassDB::register_virtual_class(); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index dd3a8aa307c..81df58a2b70 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -683,6 +683,14 @@ void EditorPlugin::remove_export_plugin(const Ref &p_exporte EditorExport::get_singleton()->remove_export_plugin(p_exporter); } +void EditorPlugin::add_spatial_gizmo_plugin(const Ref &p_gizmo_plugin) { + SpatialEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin); +} + +void EditorPlugin::remove_spatial_gizmo_plugin(const Ref &p_gizmo_plugin) { + SpatialEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin); +} + void EditorPlugin::add_inspector_plugin(const Ref &p_plugin) { EditorInspector::add_inspector_plugin(p_plugin); } @@ -775,6 +783,8 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_scene_import_plugin", "scene_importer"), &EditorPlugin::remove_scene_import_plugin); ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin); ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin); + ClassDB::bind_method(D_METHOD("add_spatial_gizmo_plugin", "plugin"), &EditorPlugin::add_spatial_gizmo_plugin); + ClassDB::bind_method(D_METHOD("remove_spatial_gizmo_plugin", "plugin"), &EditorPlugin::remove_spatial_gizmo_plugin); ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin); ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin); ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index e03aeb5d308..66a87a00d69 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -53,6 +53,7 @@ class EditorExport; class EditorSettings; class EditorImportPlugin; class EditorExportPlugin; +class EditorSpatialGizmoPlugin; class EditorResourcePreview; class EditorFileSystem; class EditorToolAddons; @@ -219,6 +220,9 @@ public: void add_export_plugin(const Ref &p_exporter); void remove_export_plugin(const Ref &p_exporter); + void add_spatial_gizmo_plugin(const Ref &p_gizmo_plugin); + void remove_spatial_gizmo_plugin(const Ref &p_gizmo_plugin); + void add_inspector_plugin(const Ref &p_plugin); void remove_inspector_plugin(const Ref &p_plugin); diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index df6c40ed021..6e0e609aa80 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -563,7 +563,7 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) { Ref gizmo_plugin; gizmo_plugin.instance(); - SpatialEditor::get_singleton()->register_gizmo_plugin(gizmo_plugin); + SpatialEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin); sep = memnew(VSeparator); sep->hide(); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index ab89d170dab..102814ca7e2 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -4818,9 +4818,9 @@ struct _GizmoPluginComparator { } }; -void SpatialEditor::_init_gizmos_menu() { - _register_all_gizmos(); +void SpatialEditor::_update_gizmos_menu() { + gizmos_menu->clear(); gizmo_plugins.sort_custom<_GizmoPluginComparator>(); for (int i = 0; i < gizmo_plugins.size(); ++i) { @@ -5124,7 +5124,8 @@ void SpatialEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - _init_gizmos_menu(); + _register_all_gizmos(); + _update_gizmos_menu(); _init_indicators(); } @@ -5260,27 +5261,27 @@ void SpatialEditor::_node_removed(Node *p_node) { } void SpatialEditor::_register_all_gizmos() { - register_gizmo_plugin(Ref(memnew(CameraSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(LightSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(AudioStreamPlayer3DSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(MeshInstanceSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(SoftBodySpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(Sprite3DSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(SkeletonSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(Position3DSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(RayCastSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(SpringArmSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(VehicleWheelSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(VisibilityNotifierGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(ParticlesGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(ReflectionProbeGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(GIProbeGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(BakedIndirectLightGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(CollisionShapeSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(CollisionPolygonSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(NavigationMeshSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(JointSpatialGizmoPlugin))); - register_gizmo_plugin(Ref(memnew(PhysicalBoneSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(CameraSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(LightSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(AudioStreamPlayer3DSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(MeshInstanceSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(SoftBodySpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(Sprite3DSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(SkeletonSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(Position3DSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(RayCastSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(SpringArmSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(VehicleWheelSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(VisibilityNotifierGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(ParticlesGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(ReflectionProbeGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(GIProbeGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(BakedIndirectLightGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(CollisionShapeSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(CollisionPolygonSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(NavigationMeshSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(JointSpatialGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(PhysicalBoneSpatialGizmoPlugin))); } void SpatialEditor::_bind_methods() { @@ -5715,8 +5716,15 @@ void SpatialEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) { spatial_editor->snap_cursor_to_plane(p_plane); } -void SpatialEditor::register_gizmo_plugin(Ref ref) { - gizmo_plugins.push_back(ref); +void SpatialEditor::add_gizmo_plugin(Ref p_plugin) { + gizmo_plugins.push_back(p_plugin); + _update_gizmos_menu(); + SpatialEditor::get_singleton()->update_all_gizmos(); +} + +void SpatialEditor::remove_gizmo_plugin(Ref p_plugin) { + gizmo_plugins.erase(p_plugin); + _update_gizmos_menu(); } SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) { @@ -5842,11 +5850,11 @@ void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref EditorSpatialGizmoPlugin::get_material(const String &p_name, EditorSpatialGizmo *p_gizmo) { +Ref EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref &p_gizmo) { ERR_FAIL_COND_V(!materials.has(p_name), Ref()); ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref()); - if (p_gizmo == NULL) return materials[p_name][0]; + if (p_gizmo.is_null()) return materials[p_name][0]; int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); @@ -5861,8 +5869,19 @@ Ref EditorSpatialGizmoPlugin::get_material(const String &p_name return mat; } +String EditorSpatialGizmoPlugin::get_name() const { + if (get_script_instance() && get_script_instance()->has_method("get_name")) { + return get_script_instance()->call("get_name"); + } + return TTR("Name-less gizmo"); +} + Ref EditorSpatialGizmoPlugin::get_gizmo(Spatial *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("get_gizmo")) { + return get_script_instance()->call("get_gizmo", p_spatial); + } + Ref ref = create_gizmo(p_spatial); if (ref.is_null()) return ref; @@ -5875,22 +5894,109 @@ Ref EditorSpatialGizmoPlugin::get_gizmo(Spatial *p_spatial) return ref; } +void EditorSpatialGizmoPlugin::_bind_methods() { +#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorSpatialGizmo") + + BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Spatial"))); + BIND_VMETHOD(MethodInfo(GIZMO_REF, "create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Spatial"))); + + ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorSpatialGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorSpatialGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1))); + ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard"), &EditorSpatialGizmoPlugin::create_handle_material, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorSpatialGizmoPlugin::add_material); + + ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorSpatialGizmoPlugin::get_material); //, DEFVAL(Ref())); + + BIND_VMETHOD(MethodInfo(Variant::STRING, "get_name")); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "can_be_hidden")); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_selectable_when_hidden")); + + BIND_VMETHOD(MethodInfo("redraw", GIZMO_REF)); + BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", GIZMO_REF, PropertyInfo(Variant::INT, "index"))); + + MethodInfo hvget(Variant::NIL, "get_handle_value", GIZMO_REF, PropertyInfo(Variant::INT, "index")); + hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; + BIND_VMETHOD(hvget); + + BIND_VMETHOD(MethodInfo("set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::VECTOR2, "point"))); + MethodInfo cm = MethodInfo("commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + cm.default_arguments.push_back(false); + BIND_VMETHOD(cm); + + BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_gizmo_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "index"))); + +#undef GIZMO_REF +} + bool EditorSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("has_gizmo")) { + return get_script_instance()->call("has_gizmo", p_spatial); + } return false; } Ref EditorSpatialGizmoPlugin::create_gizmo(Spatial *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("create_gizmo")) { + return get_script_instance()->call("create_gizmo", p_spatial); + } + Ref ref; if (has_gizmo(p_spatial)) ref.instance(); return ref; } bool EditorSpatialGizmoPlugin::can_be_hidden() const { + if (get_script_instance() && get_script_instance()->has_method("can_be_hidden")) { + return get_script_instance()->call("can_be_hidden"); + } return true; } bool EditorSpatialGizmoPlugin::is_selectable_when_hidden() const { + if (get_script_instance() && get_script_instance()->has_method("is_selectable_when_hidden")) { + return get_script_instance()->call("is_selectable_when_hidden"); + } + return false; +} + +void EditorSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { + if (get_script_instance() && get_script_instance()->has_method("redraw")) { + Ref ref(p_gizmo); + get_script_instance()->call("redraw", ref); + } +} + +String EditorSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { + if (get_script_instance() && get_script_instance()->has_method("get_handle_name")) { + return get_script_instance()->call("get_handle_name", p_gizmo, p_idx); + } + return ""; +} + +Variant EditorSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { + if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) { + return get_script_instance()->call("get_handle_value", p_gizmo, p_idx); + } + return Variant(); +} + +void EditorSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { + if (get_script_instance() && get_script_instance()->has_method("set_handle")) { + get_script_instance()->call("set_handle", p_gizmo, p_idx, p_camera, p_point); + } +} + +void EditorSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { + if (get_script_instance() && get_script_instance()->has_method("commit_handle")) { + get_script_instance()->call("commit_handle", p_gizmo, p_idx, p_restore, p_cancel); + } +} + +bool EditorSpatialGizmoPlugin::is_gizmo_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const { + if (get_script_instance() && get_script_instance()->has_method("is_gizmo_handle_highlighted")) { + return get_script_instance()->call("is_gizmo_handle_highlighted", p_gizmo, p_idx); + } return false; } @@ -5910,4 +6016,9 @@ EditorSpatialGizmoPlugin::EditorSpatialGizmoPlugin() { } EditorSpatialGizmoPlugin::~EditorSpatialGizmoPlugin() { + for (int i = 0; i < current_gizmos.size(); ++i) { + current_gizmos[i]->set_plugin(NULL); + current_gizmos[i]->get_spatial_node()->set_gizmo(NULL); + } + SpatialEditor::get_singleton()->update_all_gizmos(); } diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 3cce76cc172..fa2e1e84a2a 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -615,7 +615,7 @@ private: void _instance_scene(); void _init_indicators(); - void _init_gizmos_menu(); + void _update_gizmos_menu(); void _init_grid(); void _finish_indicators(); void _finish_grid(); @@ -710,7 +710,8 @@ public: return viewports[p_idx]; } - void register_gizmo_plugin(Ref ref); + void add_gizmo_plugin(Ref p_plugin); + void remove_gizmo_plugin(Ref p_plugin); void edit(Spatial *p_spatial); void clear(); @@ -764,6 +765,7 @@ private: HashMap > > materials; protected: + static void _bind_methods(); virtual bool has_gizmo(Spatial *p_spatial); virtual Ref create_gizmo(Spatial *p_spatial); @@ -773,18 +775,18 @@ public: void create_handle_material(const String &p_name, bool p_billboard = false); void add_material(const String &p_name, Ref p_material); - Ref get_material(const String &p_name, EditorSpatialGizmo *p_gizmo = NULL); + Ref get_material(const String &p_name, const Ref &p_gizmo = Ref()); - virtual String get_name() const = 0; + virtual String get_name() const; virtual bool can_be_hidden() const; virtual bool is_selectable_when_hidden() const; - virtual void redraw(EditorSpatialGizmo *p_gizmo) {} - virtual String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { return ""; } - virtual Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { return Variant(); } - virtual void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {} - virtual void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) {} - virtual bool is_gizmo_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const { return false; } + virtual void redraw(EditorSpatialGizmo *p_gizmo); + virtual String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; + virtual Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; + virtual void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); + virtual void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + virtual bool is_gizmo_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const; Ref get_gizmo(Spatial *p_spatial); void set_state(int p_state); diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index 5864d02615b..0d600166b64 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -356,5 +356,5 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { EditorPluginCSG::EditorPluginCSG(EditorNode *p_editor) { Ref gizmo_plugin = Ref(memnew(CSGShapeSpatialGizmoPlugin)); - SpatialEditor::get_singleton()->register_gizmo_plugin(gizmo_plugin); + SpatialEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin); } diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index cf0317cd58d..02fab8c50bf 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -138,6 +138,8 @@ void MeshInstance::set_mesh(const Ref &p_mesh) { set_base(RID()); } + update_gizmo(); + _change_notify(); } Ref MeshInstance::get_mesh() const { diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index fcc908cdc6b..82ad62014b4 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -32,6 +32,7 @@ #include "core/engine.h" #include "core/message_queue.h" +#include "scene/main/scene_tree.h" #include "scene/main/viewport.h" #include "scene/scene_string_names.h" @@ -400,6 +401,8 @@ void Spatial::update_gizmo() { #ifdef TOOLS_ENABLED if (!is_inside_world()) return; + if (!data.gizmo.is_valid()) + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this); if (!data.gizmo.is_valid()) return; if (data.gizmo_dirty)