I’m not sure if question has been asked earlier but I would like to know how to get the mouse to focus on the game again after removing a widget. For example if I make a pause menu or a short popup with text, after removing the widget with a keypress the mouse must be clicked again on screen to regain game focus. It also causes an with using a game pad because you must have a mouse at hand when playing so the controller regains input. Does anyone know of a work around for if it is not possible at time.
I’ve spent some time and effort trying to find a way to send custom events directly to the level blueprint. I first tried using an event dispatcher from the widget to the custom event in the level blueprint, but no events get though. Then following some advice, I passed a reference to self from the level blueprint through a variable to the widget, but when I try to save the widget I get an error message basically saying I can’t do that. If anyone has any other suggestions I would be most grateful to hear them. are several pictures of my setup and error message:
Hey JasonW, you should do it the other way around. The button should have a custom event that it can emit. Then when you create the widget in the level, you should bind a handler to that event.
Hey , what’s the best practice for using UMG for a pause or in-game menu?
I’m currently having the HUD spawn the widget on Begin Play, destroy the widget on End Play, and have a key to toggle visibility of a window.
I need to destroy it on end play as I want it to disappear on map transition, however when I stop playing in the editor, and the HUD End Play event causes the widget to be removed from the viewport, the whole editor crashes.
@Acren without a callstack I can’t be of much help. I can tell you there are bugs still with UI leaking between level loads (hence why you have to remove it before loading a map).
Do you believe option will be made available in the future in the editor or via blueprint?
If I were to try and adjust the code like they did in the link, can cause problems with future updates if I change the code? I’m still fairly new to C++
Hello, I tested out the preview build of 4.5 and i saw that that setOffset ( with vector 4 floats , left , right, top, bottom) was going to expire in the next version and replace it with another setOffset with input of vector2.
When i tried that new setOffset, it seems that it doesn’t have any effect. An input of , for example, (0,0) and (700,700) gives the same result ( stuck at top left corner).
SetOffsets is referring to the raw offsets structure of the canvas slot (is that what you’re talking about?) The values mean different things depending on anchor points.
Left,Top = position offset from their anchor point.
Bottom = (If vertically stretching) margin from bottom (else) height
Right = (If horizontally stretching) margin from right (else) width
So if your widget was anchored to 0,0.
0,0 700,700 means, a box at 0,0 with 700 width and height.
There is a new option “Set Offset in Viewport” with input Desired Offset (vector2). If i understand it correctly, if i add a widget, via add child, and then use new function i will be able to place the widget depending on the Desired Offset. However , an input value of (0,0) or a value of (700,700) doesn’t effect the added user widget position at all inside the viewport.
And i guess one will replace the old “Set Offsets , target CanvasPanelSlot” because i get warnings that it wasn’t tagged as BlueprintReadWrite and it will be removed in a future release.
Add To Viewport - All the viewport functions will work as long as you have Absolute Layout enabled.
Add Child - You’re not adding it to the viewport directly, you’re placing it inside another widget, so the viewport functions have no effect.
Is there a way to stretch/tile an image to a percentage of parent’s width?
Like for instance I’m making some menu, and I have background which I accomplished by putting a Border as root. But now I would like to some horizontal bars which run across the screen (or for instance runs 90% across the screen). The actual texture is only 2 pixels.
For that matter I would like any component/widget to be able to have effect.
Also is it possible to add a slate widget I created inside another widget in blueprint editor?
And another last small question, I wanted to draw a texture like a box, where I define a margin of the border and where the inside gets stretched, works fine, but in the future will it be possible to make the inside tiled instead of stretched?
Do I have to change my Build files somehow to include UMG.h in C++?
Runtime/UMG/Public/ is apparently not in my include path and including “Runtime/UMG/Public/UMG.h” directly also doesn’t help, because it will just fail to include it’s dependencies…
I’ve tried adding a class inheriting from UWidget and refreshing/recreating the project files, but that didn’t help.
Edit: Okay, after adding UMG as a module dependency in my Build.cs I might be getting somewhere.
Well, I also ran into and I’ve figured out what the problem is. Convert World Location to Screen Location / APlayerController::ProjectWorldLocationToScreen returns scaled coordinates, while setting the Full Screen Position requires absolute unscaled values.
The scaling is introduced by the Scalability Settings, r.ScreenPercentage to be specific, which the editor (automatically?) set to something less than 100%. As a workaround I can obviously just make sure r.ScreenPercentage is always 100, so no scaling occurs, but I don’t know how you would handle it if you actually wanted to use that setting.
I’m working on a project where I’ll need to display paragraph-long dialog. Can anyone tell me if UMG is able to do so at point (or ever)? I’ve played around with it a bit, but I can’t figure out a way to manage word-wrapping after displaying text/textboxes.