FairyGUI-layabox icon indicating copy to clipboard operation
FairyGUI-layabox copied to clipboard

Fairy GUI responsive in Layabox

Open skymen opened this issue 5 years ago • 2 comments

Hi,

I am having a few issues with layabox and fairy GUI with responsiveness. The UI doesn't seem to scale properly when resized. The game is currently in "fixedHeight' mode, so a lot of the time, the game scales properly, but when the aspect ratio changes, the UI elements go out of the window.

Is it possible to force FairyGUI to update the height or the aspect ratio when the game rescales? I am very limited by the fact that a lot of documentation/resources are in chinese and I sadly cannot read or understand the language so it makes it very difficult for me to know about these things if they happen to be obvious

image

skymen avatar Nov 24 '20 10:11 skymen

Once again, I found the answer by myself by reading through the source code since it turns out that none of the api has been thoroughly documented.

You need to ask FGui to update the component manually by listening to the window resize event

window.addEventListener('resize', () => {
	if (fgui.GRoot.inst.numChildren > 0)
		fgui.GRoot.inst.getChildAt(0).makeFullScreen();
});

skymen avatar Nov 25 '20 22:11 skymen