Make UI With C++: How to use Slate in Unreal Engine

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ย. 2024

ความคิดเห็น • 95

  • @xeru9865
    @xeru9865 4 ปีที่แล้ว +10

    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

  • @RandomGuyyy
    @RandomGuyyy 4 ปีที่แล้ว +14

    This helps me understand the UI code in the ShooterGame example project as that's all Slate based. Thank you!

  • @steffennilsen2132
    @steffennilsen2132 4 ปีที่แล้ว +10

    If you come from a webdev environment, the composition syntax of slate is quite easy to digest

  • @Guraw
    @Guraw 2 ปีที่แล้ว +2

    Still 100% accurate and working in UE5 early access. Thank you for a great tutorial!

  • @Teturarsyra
    @Teturarsyra 3 ปีที่แล้ว +1

    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;

  • @karthikeyatsvr3838
    @karthikeyatsvr3838 8 หลายเดือนก่อน +1

    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

  • @gamemakerdude
    @gamemakerdude 4 ปีที่แล้ว +2

    Outstanding tutorial as always! I have a request, please. Would you please consider making a tutorial on how to move pawns in a circle?

  • @IsaacCode95
    @IsaacCode95 2 ปีที่แล้ว +1

    thank you! your c++ are the best i've seen, would you consider making a c++ tutorial that is relevant to UE5 ?

  • @frankhilpert4893
    @frankhilpert4893 4 ปีที่แล้ว +1

    thank you! this is exactly what i was looking for. you have the ways of a great teacher about you. great to listen to.

  • @PBOZAI
    @PBOZAI 3 ปีที่แล้ว +5

    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.

    • @PBOZAI
      @PBOZAI 3 ปีที่แล้ว +2

      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.

  • @TechNova45
    @TechNova45 4 ปีที่แล้ว +6

    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.

  • @darkferiousity
    @darkferiousity 2 ปีที่แล้ว

    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++.

  • @noahsteam8214
    @noahsteam8214 3 ปีที่แล้ว

    Thank you for putting this together. Very helpful.

  • @irajmh
    @irajmh 4 ปีที่แล้ว +3

    Can we have a tutorial on how to add a SvirtualJoystick?

  • @robinj6997
    @robinj6997 ปีที่แล้ว

    Such a great tutorial! Thank you

  • @tophinski
    @tophinski 4 ปีที่แล้ว

    I've been considering purchasing your Survival game course and I"m wondering which version you use. Thanks, great content as always, Reuben.

    • @reubs
      @reubs  4 ปีที่แล้ว +2

      We use 4.23 in the course.

    • @tophinski
      @tophinski 4 ปีที่แล้ว +1

      @@reubs Perfect, thanks for the reply!

    • @tophinski
      @tophinski 4 ปีที่แล้ว

      @@reubs One more question, does the survival course use a projectile system or ray casting for the bullets?

  • @karthikeyatsvr3838
    @karthikeyatsvr3838 8 หลายเดือนก่อน +1

    Very Helpful🎉

  • @Aethrax8
    @Aethrax8 3 หลายเดือนก่อน

    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.

  • @Teturarsyra
    @Teturarsyra 3 ปีที่แล้ว +3

    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());
    }
    }

    • @DaBaSoftware
      @DaBaSoftware 2 ปีที่แล้ว

      Tested and works great in UE5 Preview :)

  • @RedFlowering
    @RedFlowering 3 ปีที่แล้ว

    Thx! You are My Super Great Teacher!!

  • @leonardo6631
    @leonardo6631 ปีที่แล้ว

    Great video!!

  • @Dan-zw2sc
    @Dan-zw2sc 3 ปีที่แล้ว

    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++?

  • @mourirsilfaut6769
    @mourirsilfaut6769 2 ปีที่แล้ว

    It looks weird when I change background color.

  • @Atl3m
    @Atl3m ปีที่แล้ว

    can this be done in user widget also . not slate ?

  • @demidrek-heyward
    @demidrek-heyward 3 ปีที่แล้ว

    thanks Reuben!

  • @paulhax
    @paulhax 4 ปีที่แล้ว +1

    Looks like good content. A suggestion: triple or more the editor text size. I can't read the code on my laptop screen.

  • @perregrinne2500
    @perregrinne2500 4 ปีที่แล้ว

    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!

  • @vegitoblue2187
    @vegitoblue2187 3 ปีที่แล้ว

    So in theory this slate widget could be made from anywhere not just HUD right?

  • @VampNeo
    @VampNeo 3 ปีที่แล้ว

    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

  • @StefanJann
    @StefanJann 2 หลายเดือนก่อน

    Thank you

  • @redjohn4886
    @redjohn4886 3 ปีที่แล้ว +1

    Where is the MenuGameMode class coming from ?

    • @李佳奇-w9z
      @李佳奇-w9z ปีที่แล้ว

      i think the reason is your project is a blank project.

  • @DanielOraraVA
    @DanielOraraVA 4 ปีที่แล้ว

    howcome the module is there in the files, but not automatically implemented or included?

  • @jasoncrosby8523
    @jasoncrosby8523 ปีที่แล้ว

    Coming from a mobile developer background this looks very similar to Android Compose and iOS Swift UI.

  • @biedagejming
    @biedagejming 3 ปีที่แล้ว

    Will this Survival game course be some day on Udemy ??

  • @artoriasdenostradamus3628
    @artoriasdenostradamus3628 4 ปีที่แล้ว

    The Survival game course is developed in pure c++ or both c++ and blueprints?

  • @JoshDucote
    @JoshDucote 3 ปีที่แล้ว

    how would i go about making options menu to pop up when i click it?

  • @lennysmileyface
    @lennysmileyface 4 ปีที่แล้ว

    Can you only make slate widgets that inherit from classes like SCompoundWidget?

  • @katietooher8472
    @katietooher8472 ปีที่แล้ว

    Hello, does anyone know if this is possible to create with an SWindow instead of using a HUD class?

  • @rukiandtheenok437
    @rukiandtheenok437 3 ปีที่แล้ว +1

    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 :-(

    • @ElodinMaster
      @ElodinMaster 3 ปีที่แล้ว

      I also have an error with that line. Did you find the solution?

    • @rukiandtheenok437
      @rukiandtheenok437 3 ปีที่แล้ว

      @@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

    • @ElodinMaster
      @ElodinMaster 3 ปีที่แล้ว +1

      ​@@rukiandtheenok437 Found out the problem in my case. I forgot to write the public keyword before SCompoundWidget when doing the inheritance of SMainMenuWidget

    • @maxedwardsantos
      @maxedwardsantos 2 ปีที่แล้ว

      For those that have this problem in the future, make sure you are subclassing SCompoundWidget in your SMainMenuWidget class

  • @halfbakedproductions7887
    @halfbakedproductions7887 3 หลายเดือนก่อน

    HUD Class is legacy and deprecated in UE5.

  • @arkanzock4082
    @arkanzock4082 3 ปีที่แล้ว

    Slate or UMG? Whats bettrer?

  • @张某某-m9p
    @张某某-m9p 3 ปีที่แล้ว

    how to use set a image for simage

  • @Muhammad_Abdullah_Sultan
    @Muhammad_Abdullah_Sultan ปีที่แล้ว

    Good

  • @reubs
    @reubs  4 ปีที่แล้ว +13

    1st

  • @SouravUE
    @SouravUE 4 ปีที่แล้ว

    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.

    • @kryph
      @kryph 4 ปีที่แล้ว +1

      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++.

    • @SouravUE
      @SouravUE 4 ปีที่แล้ว

      @@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?

    • @kryph
      @kryph 4 ปีที่แล้ว +1

      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.

    • @SouravUE
      @SouravUE 4 ปีที่แล้ว

      @@kryph Thanks a lot for ur time. 🙂

  • @awoidf
    @awoidf ปีที่แล้ว

    7:20-7:24 yeah, that's also known as the stockholm-syndrome xD

  • @andrew6855
    @andrew6855 4 ปีที่แล้ว

    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! :)

    • @reubs
      @reubs  4 ปีที่แล้ว +1

      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++.

    • @Teturarsyra
      @Teturarsyra 3 ปีที่แล้ว

      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.

  • @ivayloi736
    @ivayloi736 3 ปีที่แล้ว

    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...

    • @РижаМавпа-ш8и
      @РижаМавпа-ш8и 3 ปีที่แล้ว

      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.

  • @devintrusdell5733
    @devintrusdell5733 3 ปีที่แล้ว

    GOD loves y'all and have a Blessed day ✝️⛪🙏🙏🏻🙏🏼🙏🏾🙏🏽🙏🏿👼🏿👼🏾👼🏽👼🏼👼🏻👼😇🥰❤

  • @daigriff1989
    @daigriff1989 4 ปีที่แล้ว +4

    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

  • @quazitarik
    @quazitarik 2 ปีที่แล้ว

    how do I load image from local drive instead of changing color to black

  • @volkadrum
    @volkadrum 4 ปีที่แล้ว +2

    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?

  • @philboltt
    @philboltt 4 ปีที่แล้ว +2

    Thanks for this! It's a huge help in getting over that initial Slate WTF moment :) More Slate tutorials pls!

  • @faei1897
    @faei1897 3 หลายเดือนก่อน +1

    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.

  • @ayoubtouaty8255
    @ayoubtouaty8255 2 ปีที่แล้ว +1

    Can anyone tell me how to create a custom button position editor like mobile games have ❤️🙏

  • @RockWarCry
    @RockWarCry 2 ปีที่แล้ว +1

    It looks a lot like Flutter`s and Swift UI`s way of composing UIs

  • @VladyVeselinov
    @VladyVeselinov 4 ปีที่แล้ว +2

    You can really tell Epic doesn't care about UI, every UI system they have is so clunky...

    • @reubs
      @reubs  4 ปีที่แล้ว +3

      Try using cryengine! It uses flash lol

    • @VladyVeselinov
      @VladyVeselinov 4 ปีที่แล้ว +1

      @@reubs oh my

    • @ivayloi736
      @ivayloi736 3 ปีที่แล้ว +1

      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...

    • @VladyVeselinov
      @VladyVeselinov 3 ปีที่แล้ว

      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

  • @artoriasdenostradamus3628
    @artoriasdenostradamus3628 4 ปีที่แล้ว +1

    Could you do a tutorial to do for example an dynamic health bar and enemy kill counter with this method of slate ,please ?

  • @mr-lks
    @mr-lks 4 ปีที่แล้ว +1

    what is the differences between making ui on c++ or blueprint? Is there any efficiency

  • @cDogRage
    @cDogRage 6 หลายเดือนก่อน

    Thank you so much for this.

  • @DevGods
    @DevGods 4 ปีที่แล้ว

    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

  • @goken-san9224
    @goken-san9224 3 ปีที่แล้ว

    My character and the camera isn't moving after adding the slate code. What can I do to fix this?

  • @hydrogen5087
    @hydrogen5087 2 ปีที่แล้ว

    **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.

  • @wayancientmoon1142
    @wayancientmoon1142 3 ปีที่แล้ว

    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.

  • @andikarizkyoktavian8581
    @andikarizkyoktavian8581 ปีที่แล้ว

    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?

  • @Cronofear
    @Cronofear ปีที่แล้ว

    The problem with slate are the slow iteration times/slow compilation. The system itself is as simple as json.

  • @NicoleSummer8
    @NicoleSummer8 2 ปีที่แล้ว

    Awesome 🎉

  • @wisper8628
    @wisper8628 3 ปีที่แล้ว

    very nice

  • @matheus-kirchesch
    @matheus-kirchesch 3 ปีที่แล้ว

    Are you planing on a more in depth slate tutorial? would be nice

    • @matheus-kirchesch
      @matheus-kirchesch 3 ปีที่แล้ว

      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

  • @GiacomoPerin
    @GiacomoPerin 4 ปีที่แล้ว +1

    1st