Dreikblack Posted May 25, 2023 Share Posted May 25, 2023 This works in 2D UI but in 3D widget became not interactive but visible. Maybe where is another way to delete widgets in 3D UI? #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); ui_camera->SetRenderLayers(2); ui_camera->SetClearMode(CLEAR_DEPTH); auto button = CreateButton("Button", 10, 10, 120, 30, ui->root); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); if (ev.source == button && ev.id == EVENT_WIDGETACTION) { button->SetParent(NULL); } ui->ProcessEvent(ev); } world->Update(); world->Render(framebuffer); } return 0; } 1 Quote Link to comment Share on other sites More sharing options...
Solution SpiderPig Posted July 29, 2023 Solution Share Posted July 29, 2023 Just tested this. Button needs to be set to nullptr (NULL) so that it is no longer keeping the widget alive. You need to do both of these to delete the widget. Well, it goes off screen so I'm going to assume it's gone for good. button->SetParent(nullptr); button = nullptr; 2 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.