Right at the beginning when you create the widget c++ class, you can actually just scroll to the bottom of that menu and there are default constructor options for both slate widget and slate widget style that do all the default includes automatically
Very cool. What I usually do is create a C++ user widget class, then a widget blueprint and change its parent to the user widget C++ class, with that I have the flexibility of widget blueprint for adding buttons etc easily and I can use C++ for anything else like drag enter, mouse enter or anything else really.
For anyone else curious about what adding const before override does - it just goes "hey, we won't change anything about this object!". I had a copy of C++ Programming 4th. Edn. on hand and went looking. Page 307 on §12.1.2 explains the parts of a function declaration.
This has helped me a great deal! Slate code absolutely terrified me but now I understand it, and it's weird syntax a whole lot better. Thanks for the great tutorial
Best video ever. Very helpful. Also could you please do a video on how to make the buttons UI design like icons(fps, replay, file explorer icons with functionalities) and Also hover and Click animations
If you wonder what's the 'class' in 'TWeakObjectPtr OwnerHUD;' it is just a concise way to use forward declaration, it's equivalent to: class AMainHUD; TWeakObjectPtr OwnerHUD;
An issue with code at 17:21 This might be a change to more current versions of Unreal, but GEngine might be shared between multiple PIE windows. This often leads GEngine->GameViewPort to point to the incorrect viewport. This can be avoided by using something like ULocalPlayer* LocPlayer = Cast(PlayerOwner->Player); if (LocPlayer && LocPlayer->ViewportClient){ auto* VC = LocPlayer->ViewportClient; VC->AddViewportWidgetContent(SAssignNew(MenuWidgetContainer, SWeakWidget).PossiblyNullContent(MenuWidget.ToSharedRef())); and similar for VC->RemoveViewportWidgetContent The LocPlayer client is guaranteed to be the correct client for each AHUD instance in this edge case.
As of writing this only fixes a bug that occurs when multiplayer is being tested in editor. Thought, the documentation indicates that Unreal might further use this type of behavior in the future.
I bought the course before it was finished but don’t have access to the rest of the lessons! Been trying to get in touch with Reuben but he’s been absent really want to finish this course for learning purposes
Thanks so much for this great tutorial! I would love to learn more about using slate to store player input (e.g. player name) from a editable text box. Con someone help?
No need to over-complexify the code, here is a straightforward way to add your widget to the viewport with Slate: void AMyHUD::BeginPlay() { if (GEngine && GEngine->GameViewport) { mainMenuWidget = SNew(SMainMenuWidget); mainMenuWidget->owning_hud = this; GEngine->GameViewport->AddViewportWidgetContent(mainMenuWidget.ToSharedRef()); } }
my button is greyed out and when mouse hovered above it, there is no sign of my button being hovered. and i can't click the button too. is there something wrong in my code or this is bug in UE5?
Wow, awesome. I am actually following your course on Udemy also. Any chance I can learn more , I mean I want to make slate widgets customizable, like you provide a edit layout window and then the user can edit different widget position and sizes. Actually I am trying fps mobile game , and its pain to find any tutorials . Most of the tuts are also about umg and not about the slate widgets. But I came to know that for touch Interfaces slates are the way to go, but can't find good tutorial on how to make them customizable like drag and drop umg
At 3:55, I think you could just add "Slate" and "SlateCore" into the addRange line above instead of making a second line, but that's a pretty insignificant nitpick. Still a really useful tutorial. Also, just started getting back into Cryengine last week. Any tutorials there would be absolutely welcome!
Do you know how can I add textures as a png (like in UMG in unreal) to images or buttons in slate ? I will be very greatfull if you know and answer. Thanks already.
Thanks a lot for this nice tut! I thought it's just a half hour course, acutally took me one day to understant it. XD Just got one question: why my VA cannot use "Add Include" ? it is grey and I cannot click it.
**Help!** When I compile at timestamp 13:08, I get: Error C2660 'SWidget::Construct': function does not take 1 arguments How should I proceed? Kindly help me, please.
Hi I am new at dev in UE. I have a problem in my MenuHUD.cpp in this row: GEngine->GameViewport->AddViewportWidgetContent(SAssignNew(MenuWidgetContainer, SWeakWidget).PossiblyNullContent(MenuWidget.ToSharedRef())); There is an Error (E0312) on MenuWidget.ToShareRef ... I don't find any differences to your code :-(
@@rukiandtheenok437 Found out the problem in my case. I forgot to write the public keyword before SCompoundWidget when doing the inheritance of SMainMenuWidget
Hi, I wanna learn game development i really like unreal and to start in it but every one's suggesting to learn unity. What's your opinion as a beginner should i learn unreal ?? and how much time it would take to learn C++ for Unreal.
Can I tell you my opinion on it? I have worked in unity and unreal. Unity is a little bit easier to start with, but as you advance it gets to be the same level of difficulty as unreal. C++ and c# are not that different. What kind of game are you making? Unreal is great at making games look graphically amazing without much effort. Unity is best for mobile games. Unreal is not great at 2D, but It’s amazing for 3D. Unreal has blueprints which are an alternative to c++.
@@kryph Thanks for your insight. Interested in 3d games mostly small rpg like, some ar/vr and later may be something big and awesome. And how much time does c++ takes to learn?
Sourav that depends. If you already know a language like c#, you could pick it up in about 1-2 months. Without prior knowledge of a language, takes about 2-3 months to learn the basics. Unreal also has blueprints, so you could start with that.
I don't really think there is a good reason to use slate over UMG. You mentioned two reasons why you would do so: Performance and access to hidden features. As for performance, as time goes on Epic games will optimise the back-end of UMG more and more so that the performance difference won't be big enough to justify giving up ease of design. As for the hidden features, I was completely unaware of any hidden features or features only accessible through slate. Unfortunately I didn't see you mention any of these "hidden features" in the video since it seems to be catered to absolute beginners. Thanks for the great free tutorials though! It's people like you that strengthen the game dev community! :)
Thanks! An example would be the color picker widget, which isn't available through a widget blueprint. You can write very basic editor extensions with Blueprint, but most more involved extensions will require some C++.
For simple UIs and beginners I agree, for complex ones clarity will be on the C++ side not to mention speed will always be slower no matter how much Epic tries. In addition If you use the source version of UE and need for instance to extend the editor and mod things, then c++ slate knowledge is mandatory to understand and modify existing code base.
Almost all UI frameworks are just terrible. Dear ImGui became very popular because there is really nothing else remotely sane. There are bindings for UE4 btw...
I see now why they had to come up with UMG in order to expose something... more sane to BP... I get what they were trying to achieve, but breaking the language with macros and non standard style of codding, never ends well...
No, you're wrong, this is actually how normal code is wrote. If you're a designer you use prewritten stuff, but if you need more flexibility and actually making something new you will be doing this.
This helps me understand the UI code in the ShooterGame example project as that's all Slate based. Thank you!
Right at the beginning when you create the widget c++ class, you can actually just scroll to the bottom of that menu and there are default constructor options for both slate widget and slate widget style that do all the default includes automatically
Very cool. What I usually do is create a C++ user widget class, then a widget blueprint and change its parent to the user widget C++ class, with that I have the flexibility of widget blueprint for adding buttons etc easily and I can use C++ for anything else like drag enter, mouse enter or anything else really.
If you come from a webdev environment, the composition syntax of slate is quite easy to digest
For anyone else curious about what adding const before override does - it just goes "hey, we won't change anything about this object!". I had a copy of C++ Programming 4th. Edn. on hand and went looking. Page 307 on §12.1.2 explains the parts of a function declaration.
This has helped me a great deal!
Slate code absolutely terrified me but now I understand it, and it's weird syntax a whole lot better.
Thanks for the great tutorial
Still 100% accurate and working in UE5 early access. Thank you for a great tutorial!
Best video ever. Very helpful.
Also could you please do a video on how to make the buttons UI design like icons(fps, replay, file explorer icons with functionalities) and Also hover and Click animations
If you wonder what's the 'class' in 'TWeakObjectPtr OwnerHUD;' it is just a concise way to use forward declaration, it's equivalent to:
class AMainHUD;
TWeakObjectPtr OwnerHUD;
Thanks for this! It's a huge help in getting over that initial Slate WTF moment :) More Slate tutorials pls!
thank you! your c++ are the best i've seen, would you consider making a c++ tutorial that is relevant to UE5 ?
An issue with code at 17:21
This might be a change to more current versions of Unreal, but GEngine might be shared between multiple PIE windows. This often leads GEngine->GameViewPort to point to the incorrect viewport. This can be avoided by using something like
ULocalPlayer* LocPlayer = Cast(PlayerOwner->Player);
if (LocPlayer && LocPlayer->ViewportClient){
auto* VC = LocPlayer->ViewportClient;
VC->AddViewportWidgetContent(SAssignNew(MenuWidgetContainer, SWeakWidget).PossiblyNullContent(MenuWidget.ToSharedRef()));
and similar for VC->RemoveViewportWidgetContent
The LocPlayer client is guaranteed to be the correct client for each AHUD instance in this edge case.
As of writing this only fixes a bug that occurs when multiplayer is being tested in editor. Thought, the documentation indicates that Unreal might further use this type of behavior in the future.
thank you! this is exactly what i was looking for. you have the ways of a great teacher about you. great to listen to.
Outstanding tutorial as always! I have a request, please. Would you please consider making a tutorial on how to move pawns in a circle?
Very Helpful🎉
Thank you so much for this.
Thank you for putting this together. Very helpful.
This kind of reminds me using React Three Fiber which is pretty cool. I was happy I found your vids I just like doing everything in c++.
Such a great tutorial! Thank you
Can we have a tutorial on how to add a SvirtualJoystick?
Thank you
I bought the course before it was finished but don’t have access to the rest of the lessons! Been trying to get in touch with Reuben but he’s been absent really want to finish this course for learning purposes
Could you do a tutorial to do for example an dynamic health bar and enemy kill counter with this method of slate ,please ?
thanks Reuben!
Thx! You are My Super Great Teacher!!
The problem with slate are the slow iteration times/slow compilation. The system itself is as simple as json.
Thanks so much for this great tutorial! I would love to learn more about using slate to store player input (e.g. player name) from a editable text box. Con someone help?
Great video!!
I've been considering purchasing your Survival game course and I"m wondering which version you use. Thanks, great content as always, Reuben.
We use 4.23 in the course.
@@reubs Perfect, thanks for the reply!
@@reubs One more question, does the survival course use a projectile system or ray casting for the bullets?
what is the differences between making ui on c++ or blueprint? Is there any efficiency
No need to over-complexify the code, here is a straightforward way to add your widget to the viewport with Slate:
void AMyHUD::BeginPlay() {
if (GEngine && GEngine->GameViewport) {
mainMenuWidget = SNew(SMainMenuWidget);
mainMenuWidget->owning_hud = this;
GEngine->GameViewport->AddViewportWidgetContent(mainMenuWidget.ToSharedRef());
}
}
Tested and works great in UE5 Preview :)
It looks weird when I change background color.
So in theory this slate widget could be made from anywhere not just HUD right?
This seems really useful for making custom widgets. But is there an advantage over BP for doing the layout of the widgets in the HUD in C++?
my button is greyed out and when mouse hovered above it, there is no sign of my button being hovered. and i can't click the button too. is there something wrong in my code or this is bug in UE5?
Are you planing on a more in depth slate tutorial? would be nice
if not, do you have a doc or something with alot of information about it? maybe the code of a Custom Editor UI of yours
Can anyone tell me how to create a custom button position editor like mobile games have ❤️🙏
It looks a lot like Flutter`s and Swift UI`s way of composing UIs
HUD Class is legacy and deprecated in UE5.
Wow, awesome.
I am actually following your course on Udemy also.
Any chance I can learn more , I mean I want to make slate widgets customizable, like you provide a edit layout window and then the user can edit different widget position and sizes. Actually I am trying fps mobile game , and its pain to find any tutorials . Most of the tuts are also about umg and not about the slate widgets. But I came to know that for touch Interfaces slates are the way to go, but can't find good tutorial on how to make them customizable like drag and drop umg
very nice
My character and the camera isn't moving after adding the slate code. What can I do to fix this?
Awesome 🎉
At 3:55, I think you could just add "Slate" and "SlateCore" into the addRange line above instead of making a second line, but that's a pretty insignificant nitpick. Still a really useful tutorial. Also, just started getting back into Cryengine last week. Any tutorials there would be absolutely welcome!
1st
Hehehehe
Coming from a mobile developer background this looks very similar to Android Compose and iOS Swift UI.
The Survival game course is developed in pure c++ or both c++ and blueprints?
howcome the module is there in the files, but not automatically implemented or included?
Where is the MenuGameMode class coming from ?
i think the reason is your project is a blank project.
Do you know how can I add textures as a png (like in UMG in unreal) to images or buttons in slate ? I will be very greatfull if you know and answer. Thanks already.
how would i go about making options menu to pop up when i click it?
Will this Survival game course be some day on Udemy ??
can this be done in user widget also . not slate ?
how do I load image from local drive instead of changing color to black
Thanks a lot for this nice tut! I thought it's just a half hour course, acutally took me one day to understant it. XD
Just got one question: why my VA cannot use "Add Include" ? it is grey and I cannot click it.
Can you only make slate widgets that inherit from classes like SCompoundWidget?
Hello, does anyone know if this is possible to create with an SWindow instead of using a HUD class?
Looks like good content. A suggestion: triple or more the editor text size. I can't read the code on my laptop screen.
**Help!**
When I compile at timestamp 13:08, I get:
Error C2660 'SWidget::Construct': function does not take 1 arguments
How should I proceed? Kindly help me, please.
Good
Hi I am new at dev in UE. I have a problem in my MenuHUD.cpp in this row:
GEngine->GameViewport->AddViewportWidgetContent(SAssignNew(MenuWidgetContainer, SWeakWidget).PossiblyNullContent(MenuWidget.ToSharedRef()));
There is an Error (E0312) on MenuWidget.ToShareRef ... I don't find any differences to your code :-(
I also have an error with that line. Did you find the solution?
@@ElodinMaster Hi no sry. A friend of me wrote the script on his project. And I copied that stuff. I don't now whats wrong with that line
@@rukiandtheenok437 Found out the problem in my case. I forgot to write the public keyword before SCompoundWidget when doing the inheritance of SMainMenuWidget
For those that have this problem in the future, make sure you are subclassing SCompoundWidget in your SMainMenuWidget class
how to use set a image for simage
Slate or UMG? Whats bettrer?
Hi, I wanna learn game development i really like unreal and to start in it but every one's suggesting to learn unity.
What's your opinion as a beginner should i learn unreal ?? and how much time it would take to learn C++ for Unreal.
Can I tell you my opinion on it? I have worked in unity and unreal. Unity is a little bit easier to start with, but as you advance it gets to be the same level of difficulty as unreal. C++ and c# are not that different. What kind of game are you making? Unreal is great at making games look graphically amazing without much effort. Unity is best for mobile games. Unreal is not great at 2D, but It’s amazing for 3D. Unreal has blueprints which are an alternative to c++.
@@kryph Thanks for your insight. Interested in 3d games mostly small rpg like, some ar/vr and later may be something big and awesome. And how much time does c++ takes to learn?
Sourav that depends. If you already know a language like c#, you could pick it up in about 1-2 months. Without prior knowledge of a language, takes about 2-3 months to learn the basics. Unreal also has blueprints, so you could start with that.
@@kryph Thanks a lot for ur time. 🙂
I don't really think there is a good reason to use slate over UMG. You mentioned two reasons why you would do so: Performance and access to hidden features. As for performance, as time goes on Epic games will optimise the back-end of UMG more and more so that the performance difference won't be big enough to justify giving up ease of design. As for the hidden features, I was completely unaware of any hidden features or features only accessible through slate. Unfortunately I didn't see you mention any of these "hidden features" in the video since it seems to be catered to absolute beginners.
Thanks for the great free tutorials though! It's people like you that strengthen the game dev community! :)
Thanks! An example would be the color picker widget, which isn't available through a widget blueprint. You can write very basic editor extensions with Blueprint, but most more involved extensions will require some C++.
For simple UIs and beginners I agree, for complex ones clarity will be on the C++ side not to mention speed will always be slower no matter how much Epic tries. In addition If you use the source version of UE and need for instance to extend the editor and mod things, then c++ slate knowledge is mandatory to understand and modify existing code base.
7:20-7:24 yeah, that's also known as the stockholm-syndrome xD
You can really tell Epic doesn't care about UI, every UI system they have is so clunky...
Try using cryengine! It uses flash lol
@@reubs oh my
Almost all UI frameworks are just terrible. Dear ImGui became very popular because there is really nothing else remotely sane. There are bindings for UE4 btw...
Y'all I wanna say I didn't mean this in a super negative way, it's totally cool for them to have other priorities
I see now why they had to come up with UMG in order to expose something... more sane to BP... I get what they were trying to achieve, but breaking the language with macros and non standard style of codding, never ends well...
No, you're wrong, this is actually how normal code is wrote. If you're a designer you use prewritten stuff, but if you need more flexibility and actually making something new you will be doing this.
GOD loves y'all and have a Blessed day ✝️⛪🙏🙏🏻🙏🏼🙏🏾🙏🏽🙏🏿👼🏿👼🏾👼🏽👼🏼👼🏻👼😇🥰❤
1st