Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronously notify SceneTree before node is added #90707

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

janosdebugs
Copy link

@janosdebugs janosdebugs commented Apr 15, 2024

This PR is a proof-of-concept implementation for godotengine/godot-proposals#8850. Its purpose is to allow for dependency injecting tree nodes.

Note: this is a PoC and a final implementation should check if the signals are processed synchronously or possibly a virtual function would be in order. Naming should also be verified.

Testing steps

  1. Set up a standard Godot project and set up an autoload for a inject.gd file with the following contents:
class_name Injector extends Node

func _enter_tree() -> void:
	get_tree().node_adding.connect(_on_node_adding)

func _on_node_adding(node: Node) -> void:
	print("Adding node")
  1. Create a main scene with the following attached script:
class_name Main extends Node2D

func _enter_tree() -> void:
	print("Enter tree")

func _ready() -> void:
	print("Ready")

Expected output:

Adding node
Enter tree
Ready

@AThousandShips
Copy link
Member

What is insufficient with the node_added signal? It's not mentioned here or in the proposal

@janosdebugs
Copy link
Author

@AThousandShips updated the proposal to clarify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Synchronous tree notification on child change
2 participants