How do you convert a UUserWidget to a SWidget? Needed for a loadingscreen.
Hey, i have been working on getting a loading screen for my game and have gotten the basic loading screen working by using this.
But i have gotten a bit confused on how you would go about setting your own custom widget to display when loading the maps. I understand that it is this variable that should be set to the wanted widget, but i don't really understand how i would convert a UserWidget that i have created to a SWidget.
Some help would be appreciated.
(comments are locked)
|
So let me say this about UMG and Slate, UMG is UObject-compatible frontend of Slate, created to make Slate usable in blueprints (as all Slate classes are non-UObject and invisible to reflection system there for can't be used in blueprints) and all UMG widgets (with prefix U) are containers for Slate widgets (with S prefix). So slate practiclly have same widgets.... even more widgets them UMG has To get underling SWidget of UMG widget you use this function: https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Components/UWidget/TakeWidget/index.html Also alternatively you can easily construct Slate widgets, it really super easy which makes Slate very easy to use in C++, here examples: https://docs.unrealengine.com/latest/INT/Programming/Slate/Widgets/index.html But i understand you want to use UMG editor to declere Slate widgets insted ;] I don't mean to hijack the post, but I figured that I would be able to get get some pointers on getting my loading screen setup as you two seem to have it figured out. Below are screens of my header and cpp file, but there seem to be some errors that I'm running into.
What errors are you getting? Also, have you included the "MoviePlayer" module in build.CS file? Yes I added MoviePlayer into my LostEchoes.Build.cs file. My errors are pretty funky like "missing ;" but my whole game compiles and runs fine. Just that the red underlines never go away, and I don't seem to have a load screen running when I start my game. Oh, looks like errors have left after a full clean and rebuild. Sorry and thanks!
(comments are locked)
|
Follow this question
Once you sign in you will be able to subscribe for any updates here
I'm curious what you did to get it working with your UMG widgets. I attempted to essentially get a UUserWidget to the SWidget needed and when debugging it has a valid object. However I then receive a Rendering Thread exception. It works with the base load screen from FLoadingScreenAttributes::NewTestLoadingScreenWidget(). The relevant part of my Game instance is below. the wLoading essentially is where the LoadingWidget is set and then it constantly gets casted or built into an SWidget to be placed inside the movie player loading screen.
Hello, thanks in advance for your code. I referred to it, and I also met a rendering exception, not sure whether the same as you met, when I load map for the second time.
I also found
LoadingWidget
became unusable for the second time as I play in viewport, and that widget is destroyed on loading map.Then I put
LoadingWidget = CreateWidget(this, wLoading);
inBeginLoadingScreen
, and no crash occurs either in PlayInViewport or in Standalone. It works.PS. My MoviePlayer only works in Standalone (screen stuck in PlayInViewport until map is loaded). Are yours the same?