I ran into most unexpected issue - subclassing UIElement
breaks layout. I have nothing-out-of-ordinary UI layout loading which into UIElement
works fine. Everything is displayed in the middle of the screen. Then i try to subclass UIElement
and loading this layout into my subclassed object sticks all controls at top-left corner. Layouting breaks.
My class:
class WindowAnimated
: public UIElement
{
URHO3D_OBJECT(WindowAnimated, UIElement);
public:
WindowAnimated(Context* ctx) : UIElement(ctx) { }
void RegisterObject(Context* context)
{
context->RegisterFactory<WindowAnimated>(UI_CATEGORY);
URHO3D_COPY_BASE_ATTRIBUTES(UIElement);
}
};
And i do call WindowAnimated::RegisterObject()
in Setup()
of my application.
I load ui something like this:
auto window = ui->GetRoot()->CreateChild(WindowAnimated::GetTypeNameStatic());
auto xml = cache.GetResource<XMLFile>(resource);
window->LoadXML(xml->GetRoot());
window->SetStyleAuto();
Are there any other requirements when subclassing UI elements?
My layout: MainMenu.xml.csv (3.5 KB) (Rename to MainMenu.xml
).