Replies: 1 comment 1 reply
-
Since you have By the way, if you are talking about an Before going any further, know that we can reload just the scene from the scene menu, and this will trigger We have a function that is called when the script is saved or attached to a Now,
Or we could actually remove and re-add the node:
By the way, yes, we need to handle With this approach we can keep initialization on Thus, I understand the desire for a place for a custom clean up. Consider the situation when we added a tool script that creates some other nodes, connects signal and so on. These linger after we removed the tool script. The above approach would only help if we were adding a script again. For that situation a more convenient place for cleanup would be useful. However, we don't have a solution for Notice that something called when the script is detached is not possible, because that moment there would not be the method to call. And we already have something called when the new script is attached: I had the idea of coming with some generic cleanup code. I have some notes on that approach:
Things that do not work:
|
Beta Was this translation helpful? Give feedback.
-
The process of making tool scripts is often hindered by these objects getting into invalid state since resaving, attaching and deattaching scripts don't call
_ready()
,_enter_tree()
and_exit_tree
on node. I understand that this is valid behaviour, since host node itself doesn't get readded into tree, but nevertheless it causes headache and often need to reload editor in order to correctly see the results. I can see 2 different approaches to this problem:_script_attached()
and_script_deattached()
. Saving script would evoke both. This would be more explicit and potentially can skip some heavy initializing logic. However I feel this is a bit extraneous as they would most likely anyway only include calls to the same initializing/deinitializing logic which is located in existing functions.Beta Was this translation helpful? Give feedback.
All reactions