Alienhead Posted May 19 Share Posted May 19 I'm creating an Interface like so. uihotbars = CreateInterface(world, sysfont, framebuffer.size) uihotbars:SetRenderLayers(2) uihotbars.background:SetColor(0,0,0,0) But while loading a new character I wish to delete this interface so I can recreate it with different data. So I use the only means possible to remove the interface - function DestroyHotbarsUI() for t, s in pairs ( tbl_hotbarpanels ) do s.pan = nil s=nil table.remove(tbl_hotbarpanels, t) end tbl_hotbarpanels = nil uihotbars = nil collectgarbage() tbl_hotbarpanels = {} end But it still remains. Quote I'm only happy when I'm coding, I'm only coding when I'm happy. Link to comment Share on other sites More sharing options...
Josh Posted May 19 Share Posted May 19 This C++ example shows that deletion is working correctly. Are you sure there isn't a reference to the variable somewhere else in your code? #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0]); //Create framebuffer auto framebuffer = CreateFramebuffer(window); //Create world auto world = CreateWorld(); //Create main camera auto camera = CreateCamera(world); camera->SetPosition(0, 0, -3); //Create a model auto box = CreateBox(world); //Create a light auto light = CreateBoxLight(world); light->SetRange(-5, 5); light->SetRotation(34, 45, 0); //Load a font auto font = LoadFont("Fonts/arial.ttf"); //Create user interface with a semi-transparent background auto ui = CreateInterface(world, font, framebuffer->size); ui->background->SetColor(0, 0, 0, 0.5); //Create widget iVec2 sz = ui->background->ClientSize(); auto button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui->background); //Create camera auto orthocamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); orthocamera->SetClearMode(CLEAR_DEPTH); orthocamera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0); //UI will only appear in orthographic camera orthocamera->SetRenderLayers(2); ui->SetRenderLayers(2); while (true) { box->Turn(0, 1, 0); while (PeekEvent()) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWCLOSE: if (ev.source == window) { return 0; } break; default: if (ui) ui->ProcessEvent(ev); break; } } if (window->KeyHit(KEY_SPACE)) ui = nullptr; world->Update(); world->Render(framebuffer); } return 0; } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 30 Share Posted October 30 Tested in Lua, to be sure. There must be another reference to the variable in question somewhere. -- Get the displays local displays = GetDisplays() -- Create window local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1]) -- Create framebuffer local framebuffer = CreateFramebuffer(window) -- Create world local world = CreateWorld() -- Create main camera local camera = CreateCamera(world) camera:SetPosition(0, 0, -3) -- Create a model local box = CreateBox(world) -- Create a light local light = CreateBoxLight(world) light:SetRange(-5, 5) light:SetRotation(34, 45, 0) -- Load a font local font = LoadFont("Fonts/arial.ttf") -- Create user interface with a semi-transparent background local ui = CreateInterface(world, font, framebuffer.size) ui.background:SetColor(0, 0, 0, 0.5) -- Create widget local sz = ui.background:ClientSize() local button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui.background) -- Create orthographic camera local orthocamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC) orthocamera:SetClearMode(CLEAR_DEPTH) orthocamera:SetPosition(framebuffer.size.x * 0.5, framebuffer.size.y * 0.5, 0) -- UI will only appear in orthographic camera orthocamera:SetRenderLayers(2) ui:SetRenderLayers(2) while true do box:Turn(0, 1, 0) while PeekEvent() do local ev = WaitEvent() if ev.id == EVENT_WINDOWCLOSE then if ev.source == window then return 0 end else if ui then ui:ProcessEvent(ev) end end end if window:KeyHit(KEY_SPACE) then ui = nil button = nil collectgarbage() end world:Update() world:Render(framebuffer) end However, I did find that sprites are not getting hidden if the widget is assigned NULL as a parent... Quote My job is to make tools you love, with the features you want, and performance you can't live without. 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.