I wanted to know if there was a mean to enable/disable all child with their parents (when targeting the parent).
Apparently no, but I wanted to be sure, because it’s something that looks logical to me.
I wanted to know if there was a mean to enable/disable all child with their parents (when targeting the parent).
Apparently no, but I wanted to be sure, because it’s something that looks logical to me.
For gui or game objects?
For gui nodes you can use gui.set_enabled(node,enabled)
This should also disable any child nodes.
When it comes to game objects you should keep track of any go’s you want to disable/enable.
Thanks. Sad. It complicate horribly objects made of multiples other objects.
In general we have no broadcast system of messages in Defold, and the connection between parented game objects is weak from an engine standpoint. Yes, parented game objects inherit the transforms but that is about it. There are no other connections or mechanisms tying them together.
If you need to communicate with a hierarchy of objects you need to manage the list yourself. I suppose you already are in some sense?
Well, I just put the function one after the other. If I want to disable all a hierarchy, I put a disable function for all the objects in the hierarchy one after the other. I’m multiplicating lines of codes as somebody else multiplied fishs.
This may be a code structuring issue. I don’t know the layout of your project but off the top of my head, this could be solved with re-usable functions in modules (meaning no code duplication) or by having a centralised manager script (which stores a list of all relevant objects and handles enabling/disabling on their behalf, among other things).
I don’t understand what you mean.
If I have an object with other objects as his childs (via a collection/collectionfactory) and I want to enable/disable it, I need to put an order enable/disable for each of it . If it’s something complex (imagine a ship with add-on), I have to put a order for every object present.
Don’t seem like a code structuring issue : Each and every object present have to be enabled/disabled independently, then each needs its own line of code or, probably worse, using an array that list all the child objects (worse because less clear).