summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-09-16 12:08:02 +0200
committerGitHub <noreply@github.com>2021-09-16 12:08:02 +0200
commit3a41a91b7a9f75a54c033523c036a74b1406d2d1 (patch)
tree0476d2e11dc9d3b22bdc97253af903773dfbf5a9 /editor/plugins
parent9e0f8110ade8e5f5fc4dde98fdf5eb5fe52e2d7a (diff)
parent05697ee848d0f17605fe3416da57c0fcc2eb6323 (diff)
Merge pull request #49284 from Calinou/add-listener3d-gizmo-icon
Display a editor gizmo icon for Listener3D
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/node_3d_editor_gizmos.cpp25
-rw-r--r--editor/plugins/node_3d_editor_gizmos.h13
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp1
3 files changed, 37 insertions, 2 deletions
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp
index e61571edff..7962d186dc 100644
--- a/editor/plugins/node_3d_editor_gizmos.cpp
+++ b/editor/plugins/node_3d_editor_gizmos.cpp
@@ -1481,8 +1481,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
}
-//////
-
//// player gizmo
AudioStreamPlayer3DGizmoPlugin::AudioStreamPlayer3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1));
@@ -1621,6 +1619,29 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
//////
+Listener3DGizmoPlugin::Listener3DGizmoPlugin() {
+ create_icon_material("listener_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoListener3D", "EditorIcons"));
+}
+
+bool Listener3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<Listener3D>(p_spatial) != nullptr;
+}
+
+String Listener3DGizmoPlugin::get_gizmo_name() const {
+ return "Listener3D";
+}
+
+int Listener3DGizmoPlugin::get_priority() const {
+ return -1;
+}
+
+void Listener3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
+ const Ref<Material> icon = get_material("listener_3d_icon", p_gizmo);
+ p_gizmo->add_unscaled_billboard(icon, 0.05);
+}
+
+//////
+
Camera3DGizmoPlugin::Camera3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8));
diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h
index 415ed5da5c..5dace06cd7 100644
--- a/editor/plugins/node_3d_editor_gizmos.h
+++ b/editor/plugins/node_3d_editor_gizmos.h
@@ -249,6 +249,19 @@ public:
AudioStreamPlayer3DGizmoPlugin();
};
+class Listener3DGizmoPlugin : public EditorNode3DGizmoPlugin {
+ GDCLASS(Listener3DGizmoPlugin, EditorNode3DGizmoPlugin);
+
+public:
+ bool has_gizmo(Node3D *p_spatial) override;
+ String get_gizmo_name() const override;
+ int get_priority() const override;
+
+ void redraw(EditorNode3DGizmo *p_gizmo) override;
+
+ Listener3DGizmoPlugin();
+};
+
class Camera3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(Camera3DGizmoPlugin, EditorNode3DGizmoPlugin);
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index be5d756444..875474253d 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -6863,6 +6863,7 @@ void Node3DEditor::_register_all_gizmos() {
add_gizmo_plugin(Ref<Camera3DGizmoPlugin>(memnew(Camera3DGizmoPlugin)));
add_gizmo_plugin(Ref<Light3DGizmoPlugin>(memnew(Light3DGizmoPlugin)));
add_gizmo_plugin(Ref<AudioStreamPlayer3DGizmoPlugin>(memnew(AudioStreamPlayer3DGizmoPlugin)));
+ add_gizmo_plugin(Ref<Listener3DGizmoPlugin>(memnew(Listener3DGizmoPlugin)));
add_gizmo_plugin(Ref<MeshInstance3DGizmoPlugin>(memnew(MeshInstance3DGizmoPlugin)));
add_gizmo_plugin(Ref<OccluderInstance3DGizmoPlugin>(memnew(OccluderInstance3DGizmoPlugin)));
add_gizmo_plugin(Ref<SoftBody3DGizmoPlugin>(memnew(SoftBody3DGizmoPlugin)));