UI Button Example - Urho3d Typing CST Test
Loading…
UI Button Example — Urho3d Code
Creates a simple UI button and responds to click events.
#include <Urho3D/Engine/Application.h>
#include <Urho3D/UI/Button.h>
#include <Urho3D/UI/UI.h>
#include <Urho3D/UI/Text.h>
using namespace Urho3D;
class UIButtonApp : public Application {
public:
UIButtonApp(Context* context) : Application(context) {}
void Setup() override {}
void Start() override {
Button* button = GetSubsystem<UI>()->GetRoot()->CreateChild<Button>();
button->SetPosition(300,200);
button->SetSize(200,80);
Text* buttonText = button->CreateChild<Text>();
buttonText->SetText("Click Me");
buttonText->SetFont(GetSubsystem<ResourceCache>()->GetFont("Fonts/Anonymous Pro.ttf"),40);
button->SubscribeToEvent(button, E_RELEASED, URHO3D_HANDLER(UIButtonApp, HandleButton));
}
void HandleButton(StringHash eventType, VariantMap& eventData) {
URHO3D_LOGINFO("Button Clicked!");
}
};
URHO3D_DEFINE_APPLICATION_MAIN(UIButtonApp)Urho3d Language Guide
Urho3D is an open-source, cross-platform 2D and 3D game engine written in C++ with optional AngelScript and Lua scripting. It provides a lightweight, flexible environment for building games and real-time simulations.
Primary Use Cases
- ▸2D and 3D PC games
- ▸Mobile games (Android/iOS)
- ▸Educational simulations
- ▸Real-time visualizations
- ▸Interactive prototypes
Notable Features
- ▸C++ core with scripting via AngelScript/Lua
- ▸Cross-platform (Windows, macOS, Linux, iOS, Android)
- ▸Scene graph and node-based architecture
- ▸Integrated physics (Bullet Physics) and networking
- ▸Flexible rendering pipeline (shaders, lights, shadows)
Origin & Creator
Urho3D was created in 2007 by the Finnish developer Jukka Jylänki, later developed and maintained by a community of contributors.
Industrial Note
Urho3D is valued by developers seeking a lightweight, open-source engine with full access to C++ code, cross-platform deployment, and integrated physics and rendering systems.