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"

Finding out good workflow for working with widgets (main menu)

Hi!

I have trouble understanding how I should implement main menu screen in my game, using both c++ and blueprints and make best use of the engine.

Right now I have implemented my main menu as mentioned below:

  1. I created UserWidget blueprint class (so it would be easy to design it there)

  2. As my whole project is based on c++, I also created HUD class, that´s associated with my gamemode class

  3. Now I created an instance of UserWidget in my HUD class based on the blueprint I created and set it up

------------------------.h file --------------------------------

     UPROPERTY(EditDefaultsOnly, Category = ComponentClasses)
     TSubclassOf<UUserWidget> MainMenuWidgetClass;
 
     UPROPERTY(BlueprintReadOnly, Category = Components)
     UUserWidget* MainWidget;

  

------------------------.cpp file --------------------------------

 MainMenuWidgetClass = StaticLoadClass(UUserWidget::StaticClass(), nullptr, 
         TEXT("/Game/2DSideScrollerCPP/Blueprints/Menu/MainMenuWidget.MainMenuWidget_c"));

  

------------------------.cpp file widget to viewport --------------------------------

     MainWidget = CreateWidget<UUserWidget>(GetWorld(), MainMenuWidgetClass);
     MainWidget->AddToViewport();
     GetOwningPlayerController()->bShowMouseCursor = true;

  

Now when I press on the button in my widget blueprint, the event will fire and I call the UFUNCTION exposed function based on the button. But the example logic looks like this (note that Start Game function is the exposed function at the moment): alt text

It seems to me that I might be doing this a bit wrong (what I mean is the workflow). Maybe there are some good practices that I could take in count when I create the main menu or you have experienced some better workflows during creating UI. I would very much appreciate every advice. Thank you in advance!

Best wishes

Product Version: UE 4.16
Tags:
capture.png (88.0 kB)
more ▼

asked Jul 17 '17 at 08:12 PM in C++ Programming

avatar image

Rasponien
129 7 11 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
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