Game Development Community

How do you clone() a guicontrol?

by practicing01 · in Torque 2D Beginner · 06/29/2013 (6:49 am) · 1 replies

I want to load one guicontrol from taml and clone() it. I tried %guicontrol_clone=guicontrol_template.clone(); and it didn't work (psudo names used here). I'm using development branch. Edit: Figured out a work-around by renaming the guicontrol and instead of cloning, reloading (calling tamlread() again creates a new guicontrol). Still curious about clone() though.

#1
06/29/2013 (11:37 am)
I've briefly looked at the functionality,

The results with sceneobjects work fine, but cloned GuiControls simply do not work.

Even when setting copyDynamicFields to true, the Image field remains empty and the cloned object doesn't contain children.

Run %guicontrol_template.getcount(); and %guicontrol_clone.getCount(), the clone will contain 0 objects.

As for renaming the GuiControls, if you set a specific name in your .taml file, such as Name = "test", re-reading the same file will inevitably overwrite the previous instance of this Named object.