Skip to content

Commit 9146bd1

Browse files
committed
Polyfill Node.is_part_of_edited_scene()
Godot 4.3+ exposes `Node.is_part_of_edited_scene()` to GDScript, which is analogous to `Engine.is_editor_hint()` but determines whether the `@tool` script's node is itself being edited, as opposed to instantiated elsewhere in the editor. Reimplement this function in GDScript. https://phabricator.endlessm.com/T35540 Move node_is_part_of_edited_scene to new Util module This will allow it to be reused in other scenes which have the same problem as tooltip did.
1 parent 633e4a1 commit 9146bd1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

addons/block_code/ui/util.gd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extends Object
2+
3+
4+
## Polyfill of Node.is_part_of_edited_scene(), available to GDScript in Godot 4.3+.
5+
static func node_is_part_of_edited_scene(node: Node) -> bool:
6+
return Engine.is_editor_hint() && node.is_inside_tree() && node.get_tree().edited_scene_root && node.get_tree().edited_scene_root.get_parent().is_ancestor_of(node)

0 commit comments

Comments
 (0)