x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

 void UHomeInvasionGameInstance::Init()
 {
     UGameInstance::Init();
 
     FCoreUObjectDelegates::PreLoadMap.AddUObject(this, &UHomeInvasionGameInstance::BeginLoadingScreen);
     FCoreUObjectDelegates::PostLoadMap.AddUObject(this, &UHomeInvasionGameInstance::EndLoadingScreen);
 }
 
 void UHomeInvasionGameInstance::BeginLoadingScreen()
 {
     FLoadingScreenAttributes LoadingScreen;
     LoadingScreen.bAutoCompleteWhenLoadingCompletes = false;
     LoadingScreen.MinimumLoadingScreenDisplayTime = MinLoadTime;
     LoadingScreen.WidgetLoadingScreen = FLoadingScreenAttributes::NewTestLoadingScreenWidget();
 
     GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
 }
 
 void UHomeInvasionGameInstance::EndLoadingScreen()
 {
 
 }

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.

     /** The widget to be displayed on top of the movie or simply standalone if there is no movie. */
     TSharedPtr<class SWidget> WidgetLoadingScreen;

Some help would be appreciated.

Product Version: UE 4.10
Tags:
more ▼

asked Jan 08 '16 at 04:45 PM in C++ Programming

avatar image

Solicio
200 54 53 64

avatar image alsanoja Jul 31 '17 at 10:28 PM

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.

   UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
     TSubclassOf<class UUserWidget> wLoading;
 
   UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
   UUserWidget* LoadingWidget;
 
 private:
   TSharedPtr < class SWidget > loadswidget;
 
 
 void UCustomGameInstance::Init()
 {
   UGameInstance::Init();
 
   FCoreUObjectDelegates::PreLoadMap.AddUObject(this, &UCustomGameInstance::BeginLoadingScreen);
 
   FCoreUObjectDelegates::PostLoadMap.AddUObject(this, &UCustomGameInstance::EndLoadingScreen);
 
   LoadingWidget = CreateWidget(this, wLoading);
   loadswidget = LoadingWidget->TakeWidget();
 }
 
 void UCustomGameInstance::BeginLoadingScreen(const FString& MapName)
 {
     FLoadingScreenAttributes LoadingScreen;
 
     LoadingScreen.bAutoCompleteWhenLoadingCompletes = true;
     LoadingScreen.WidgetLoadingScreen = loadswidget;
 
     GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
 
 
 }
avatar image RHZhang Dec 11 '17 at 08:54 AM

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); in BeginLoadingScreen, 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?

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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 ;]

more ▼

answered Jan 08 '16 at 05:32 PM

avatar image

Shadowriver
35.2k 921 166 1098

avatar image Solicio Jan 08 '16 at 08:26 PM

That is perfect, works just like i want it. Thanks!

avatar image fishbone94 Jan 12 '16 at 12:01 AM

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.

alt text alt text

avatar image Solicio Jan 12 '16 at 08:08 AM

What errors are you getting? Also, have you included the "MoviePlayer" module in build.CS file?

avatar image fishbone94 Jan 12 '16 at 06:08 PM

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.

avatar image fishbone94 Jan 12 '16 at 06:27 PM

Oh, looks like errors have left after a full clean and rebuild. Sorry and thanks!

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question