Godot Version
v4.5.1.stable.mono.official [f62fdbde1]
Problem
Whenever I save changes in my .blend file, a reimport of the model’s scene file in Godot is automatically performed. When this happens, the signal in my scene that I have connected to the model file’s AnimationPlayer in the Editable Children gets removed.
Node panel showing signals on right, and scene tree showing signal owner (green) and connected AnimationPlayer (red).
When the model is reimported, the signal is no longer connected (either fully or “partially”).
Question
Is there a way to maintain signals connected to Editable Children when the object is reimported?
Connect from script code.
I did. Let script in Minigame connect itself to the signal at startup.
I don’t want to argue about semantics but I phrased my question the way I did because I wanted an answer to a specific problem. I’m well aware of other options for connecting the signal, but that’s not what my question is concerned with.
Question:
Is there a way to maintain signals connected to Editable Children when the object is reimported?
If you can’t answer the question, don’t answer.
Yes, sir! Understood! I can answer your question exactly as it’s phrased.
There is.
1 Like
Not the way you intend it based on your question.
There are two ways to do it:
- What @normalized said. GDScript pseudocode:
@onready var minigame: Minigame = $Minigame
func _ready() -> void:
minigame.OnCompleted.connect(PlayAnimationIdx)
func PlayAnimationIdx() -> void
#Your code runs as normal.
- Add something to your import script to hook the component back up. The main issue with this is every item would be updated. If that’s ok, this will work. But you will have to basically hardcode it assuming the locations unless there’s a pre-update hook you can run to pull existing connections. (There might be.)
1 Like
Alright then. I guess the next best thing is to add a script to the root of the model which gets and plays the AnimationPlayer instance at runtime. It should let me connect the signal without having it break while iterating on the model.
Option #1
I’d rather not connect the signal via the Minigame script since it makes the script too specialized for its intended purpose. Maybe I’ll make a specialized class for this one specific minigame which connects the signal as suggested.
Option #2
I can’t use an import script for this case because the Minigame node is not part of the model scene. It’s outside of the scene context.
1 Like
I don’t want to argue about semantics, but that’s not what you specifically asked for. Although that’s probably the best thing to do. Connecting something from the outside to something inside breaks the component encapsulation. Make the interface in component’s top node and let the component deal with its internals on its own.
Any tool script, including import scripts, has access to the whole editor context.
I’ll just pretend you didn’t say this.
I’m well aware, which is why I’m not doing that.
Took the words right out of my mouth.
Aah okay. I didn’t know.
Questionable, because that’s exactly what you were vehemently insisting on doing.