Skip to content

Editor does not fire a NOTIFICATION_TRANSFORM_CHANGED to _notification(what), when used in EditorPlugin plugin class to move a node #108062

Open
@wyattbiker

Description

@wyattbiker

Tested versions

v4.4.1.stable.official [49a5bc7]

System information

Kubuntu 24.04 KDE Plasma Version: 5.27.12

Issue description

Editor does not fire a NOTIFICATION_TRANSFORM_CHANGED to _notification(what), when used in EditorPlugin plugin class to move a node in editor.

Steps to reproduce

  1. Create empty Node3D
  2. Create child MeshInstance3D box meshes.
  3. Add plugin.gd and .cfg code (see below) to addons subfolder editor_notif
  4. Enable plugin
  5. Select a MeshInstance node and move it using the gizmo.
  6. Noticed that _notification() callback does not detect the position change

plugin.gd

@tool
extends EditorPlugin

var selected_node:Node3D

func _enter_tree():
	# Get the EditorInterface singleton.
	var editor_interface = get_editor_interface()
	# Connect to the selection_changed signal.
	editor_interface.get_selection().connect("selection_changed", Callable(self, "_on_selection_changed"))
	
func _exit_tree():
	# Disconnect the signal when the plugin is removed.
	var editor_interface = get_editor_interface()
	editor_interface.get_selection().disconnect("selection_changed", Callable(self, "_on_selection_changed"))

func _on_selection_changed():
	# Get the currently selected nodes.
	var selected_nodes = get_editor_interface().get_selection().get_selected_nodes()
	# Check if any nodes are selected.
	if selected_nodes.size() > 0:
		# Get the first selected node.
		print("\n\nClass:", selected_nodes[0].get_class())
		selected_node = selected_nodes[0]
		print("Selected node: ", selected_node, " ",selected_node.basis)
		# Node's 'mesh' property is not null
		selected_node.set_notify_transform(true)
		selected_node.set_notify_local_transform(true)
	else:
		selected_node = null
		print("No node selected.")

func _notification(what):
	if what == selected_node.NOTIFICATION_TRANSFORM_CHANGED:
		print("Global transform changed")
	elif what == selected_node.NOTIFICATION_LOCAL_TRANSFORM_CHANGED:
		print("Local transform changed")

plugin.cfg

[plugin]

name="editor_notif"
description="notif"
author="wyattbiker"
version="1.0-BETA"
script="plugin.gd"

Image

Minimal reproduction project (MRP)

editor_notif Plugin Zip

Extract to addons/ folder called editor_notif. Enable in Project > Plugins

Archive.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions