Hello,
I would like to duplicate certain UI elements in order to have “template” elements that go beyond the defaultStyle settings. Since there is no copy constructor I tried doing this with the SaveXML(XMLElement& dest) & LoadXML(XMLElement& source) functions as follows:
Urho3D::Button* buttonTemplate = ...
XMLElement templateStyle;
buttonTemplate->SaveXML(templateStyle);
Urho3D::Button* duplicateButton = new Button(context_);
duplicateButton->LoadXML(templateStyle);
Sadly this fails, SaveXML returns false, the XMLElement and the duplicate remain without any attributes. Saving into a file for test purposes like this works as expected though, the file contains all the attributes
Urho3D::File serializedFile(context_, "test.xml", FILE_WRITE);
buttonTemplate->SaveXML(serializedFile);
What am I doing wrong? Is there a better way to achieve this?
Thanks!
As said, I am not entirely sure why it has to be like this and it certainly seems like it is not completely intended to be used like this but… it works. So that is good enough for me currently