My first rookie mistake in Urho3D

Today I made my first rookie mistake.
It involved UI, and please note, I am completely new to Urho3D and its workflow.

I had some code that called UI::SetDefaultStyle for UI elements:
ui_->GetRoot()->SetDefaultStyle(cache->GetResource(“UI/DefaultStyle.xml”));

Later, I had some code to set up a splash screen, and based on public examples, I brainlessly had this:

        UI* ui = GetSubsystem<UI>();
        BorderImage* splashUI = new BorderImage(context_);
        splashUI->SetName("Splash");
        texture = cache->GetResource<Texture2D>("Textures/LogoLarge.png");
        splashUI->SetTexture(texture); // Set texture
        splashUI->SetSize(texture->GetWidth(), texture->GetHeight());
        splashUI->SetAlignment(HA_CENTER, VA_CENTER);
        ui->GetRoot()->AddChild(splashUI);

        splashUI->SetStyleAuto(); // <-- here's the culprit

What this does?
It sets the Texture of my UI Element to be the one used by the built-in UI elements.
Even though I could check my loaded texture name, size, etc was the one I thought I loaded, I would see the UI atlas texture instead.
It overrides the texture you thought you set, for that element.

I’ve learned my first lesson - don’t brainlessly attempt to string together code from different places, have a look at what it actually does!

1 Like

But calling SetStyleAuto earlier would solve it, right?

I’ll find out! But setting it later definitely didnt - my texture setting was ignored.

Which makes sense to me, since it is a style property which would be overridden by SetStyleAuto.

I’m glad it makes sense to you, but its not well documented. In fact, the documentation needs a dust-off in general, and is entirely missing in parts, such as physics, which I might consider adopting.

Often the samples provided with Urho’s source, or the engine’s code itself are most informative. Since Bullet is used for (3D) physics its documentation may be useful at times as well.

I am well familiar with both box2d and bullet engines, I should be fine to advise on both, once I check the bindings

this also opens the possibility of filling in some gaps in the docs for urho

1 Like

I’m also pretty handy with networking, and though I am not a friend of the latest network lib, I am sure I can grok it and advise on it very soon

Note that there is also a wiki, which is more suitable for things like tutorials. Honestly I kind of like the bare essentials documentation approach.

The wiki has missing holes for networking, and physics

I offer to assist, in all humility, and try to fill some missing gaps

what is the point of the engine being capable, if there is no public point of presence to learn it, or at least associate it with what you may already know? we should (hell I am already using the queens language) make it accessible. The more accessible it is, the more people will use it.

its ok for us who already know bullet or box2d or any number of other core systems but if we cant explain our bindings, we’re just talking to ourselves

Lets say I DID know bullet, or box2d, and wanted to code in angelscript, which is I assume the preferred scripting language we support. Where can I learn about the bindings?

More to the point, where can I learn the engine api?

It all exists, just not on wiki, am I wrong? Have we got NO DOCS for the physics or networking?

Please correct me, and the wiki if I am wrong

I think the code samples are quite complete, up-to-date and well commented. They are available in C++ and AS.

2 Likes

Code samples are not useful for a starting point, they rely on a base class for sample apps, which hides most useful information for new users