It should activate the object, and set the child with the corresponding name value to be activated, but somehow it requires two click execute the setActive line, on first click it looked like the setActive line it is not executed.
GenerateBubur() is a function that returns a GameObject (the activated certain object that have a couple children in it).
Well actually name is a string parameter from this line:
public void CreateItem (string name)
And the name string is being send from the button, it is funny though on the second click on that same button it works, it seems like it needed to wait a bit after the GenerateBubur() executed.
function hook up to a UI button and it’s working fine…
think we’re going to need that long chain instruction broken down into pieces and more debug.log lines to see where it’s going wrong as @WheresMommy suggested
Could it be the problem with my code is the script reside on another empty object, and the variable “buburOnScene” are actually another game object retrieved from the pool using “GenerateBubur()” function, and the script is trying to access the “buburOnScene” child object.
Actually activate the parent gameobject first, dunno though if there is a delay on activating, and executing the setActive line, but I got an idea on how to work around this, need to test it first though…
I Finally got it working, by setting the buburOnScene initializing script (another script than this one), too disable all other child gameObject except the one that I need to be activated from start.
Before this, the script disable all the child object, and when pressing the create button, it activates the parent object, but fail to activate the first child object. So as a work around, when it iterates thru its child, the script check for a child with a certain name, if its match, don’t disable the gameObject. And it is working now. Thanks a lot @WheresMommy , @LeftyRighty and @GNGification for the helps