Jump to content

Current GUI vs. MainWindow


photo

Recommended Posts

Posted

What's the difference between adding a widget to GUI.GetCurrent().addChild() vs. using WindowManager.MainWindow.addChild()?

Posted

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!

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted
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.

  • Thanks 1
×
×
  • Create New...