webnetweaver Posted July 23, 2025 Posted July 23, 2025 What's the difference between adding a widget to GUI.GetCurrent().addChild() vs. using WindowManager.MainWindow.addChild()?
silent Posted July 24, 2025 Posted July 24, 2025 Hello! If you are working specifically with windows, then you need to use EngineWindowViewport::addChild(). Gui::getCurrent() is kept for compatibility. This method returns the GUI of the window currently being worked on (either updating or rendering). The window manager loops through the windows and updates the current engine.gui at each step. Additionally, getCurrent() can return engine.default_gui when there are no windows at all. Thanks! 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
webnetweaver Posted July 25, 2025 Author Posted July 25, 2025 22 hours ago, silent said: Hello! If you are working specifically with windows, then you need to use EngineWindowViewport::addChild(). Gui::getCurrent() is kept for compatibility. This method returns the GUI of the window currently being worked on (either updating or rendering). The window manager loops through the windows and updates the current engine.gui at each step. Additionally, getCurrent() can return engine.default_gui when there are no windows at all. Thanks! Thank you for the explanation. I think there is a mistake in the code samples for UserInterface documentation: https://developer.unigine.com/en/docs/2.20/api/library/gui/class.userinterface?rlang=cs#intro Scroll down to WidgetLifetimeWorld.cs and WidgetLifetimeEngine.cs. Both scripts have Init() and Update() methods twice in the class. 1
fox Posted July 25, 2025 Posted July 25, 2025 32 minutes ago, webnetweaver said: I think there is a mistake in the code samples for UserInterface documentation: https://developer.unigine.com/en/docs/2.20/api/library/gui/class.userinterface?rlang=cs#intro Scroll down to WidgetLifetimeWorld.cs and WidgetLifetimeEngine.cs. Both scripts have Init() and Update() methods twice in the class. Thanks for pointing out, we'll fix that and update the Docs! 1
Recommended Posts