Special thanks to iLLo and Wraiyth for getting me started. And all those in this Q/A who helped me along.
If anyone wants to add some markup to this wiki page, a table of contents, adding it to the code/tutorial categories that would be appreciated. I may do that tomorrow night if nobody else does, but I gotta say I’m beat, it’s time for me to retire. The last thing I’m doing is dropping this link in a few “help me with Slate!” type Q/As and threads and then I’m passing out.
One last thing, I’ve been working on this all day and I’m really tired. I screwed up this wiki page for a moment, posting my tutorial inside of it, but I reverted all the changes I made and it appears to be fine now, just ignore/delete the “Bleakwise” edits.
Just out of curiosity is the purpose of this tutorial meant to explain slate , or one way to expand to your own type of custom slate widgets? The reason why I ask is because their are predefined Slate widgets that can be build with SNew() ,and it would be good starting point before making your own. This is how editor was made if you look in Engine/Source/Editor
Technically, you make one widget that’s made up of a bunch of other widgets, so it’s always going to be a custom widget in a sense. This tutorial explains how to implement a very basic Slate widget. You can’t use the specific widgets from the editor because, well, they’re specific.
Also, SNew (Or SAssignNew) is always used when creating a widget, predefined or not, in this tutorial they look like this:
I spent the better part of yesterday trying to figure out how to load resources (like textures) into the Slate UI. I finally figured out it with a bit of help from one very talented member of the community, Jamie Dale.
An example of what you will be able to achieve with this is in the screenshot below (it’s only all black because I’m in debug mode and have no baked lights).
@Agentlo, Ineni.RealTime is exactly correct. An example of a “master widget” (for lack of better word) is below. This is some of the code involved int he above screenshot. The rest of it can be found on the AnswerHUB, organizing it is up to you, although my tutorial provides some basic guidance, your design is ultimately your own. Personally I’m following the RTS/FPS code examples pretty close, I think it’s useful to have a code-base familiar with the community in-case I’m ever in the position to do any recruiting.
As you can see, the only widget that is my own is SMyUIWidget, which is almost exactly how it is defined in my tutorial. All of it’s child widgets are standard Slate widgets, although they don’t have to be, I’m currently thinking of subclassing SImage to make an SAbility widget that will overload it adding the ability for designers to easily change their properties in the Blueprint Editor (a combination of components and Widgets), they also need to handle mouse/keyboard events (good reason to overload), they also need to be editable real time, such as if the player drags and drops them onto another ability widget, that can be done with a custom event and a FAbilityProperties data struct. In the longer term I’ll probably subclass SHorizontalBox also, and add some functionality there too, but first I need to continue my audit to figure out what all Epic has already done for us.
I was having a weird bug where my Slate Brushes would load from the editor’s “play” mode, and when launching the editor with the “-game” switch, but not when launching the game from within the editor or a game target in visual stuido.
I found out that Slate UI Brushes have to be in the
directory, or sub-directory as the engine searches sub-directories recursively.
Epic staff has been very helpful.
Now I can show off my spell-bar (only created 1 image so far, i’m no artist) with pretty cooked-graphics!
Your Slate assets can go anywhere (note that fonts loaded directly from disk must currently reside somewhere in /Content/Slate in order to be packaged correctly), but I guess your FSlateGameResources was looking in /Game/UI?
If anyone has been following my progress on Slate and has any questions feel free to PM me. There is only one more issue I have to tackle then I’m moving onto events and writing C++ classes for the Blueprint editor. The last thing I’m going over on slate for now is the proper releasing of resources for avoidance of memory leaks/errors. Once I get this section of code complete I plan on updating the wiki with the missing info and then it will be time to move on.
After I have a grasp on writing Blueprint classes I plan to work on a blueprint/slate library, so blueprint designers can build (at least basic) Slate UIs without touching any code. Stay tuned!
Evidently the brushes were not being cooked (baked?). My options were eitehr 1) add /game/slate to the editor.ini list above, or 2) move resources to /Game/UI. I chose the latter, I don’t think Epic really wants us messing with the .ini files though (can cause strange bugs), so it’s recommended that Slate UI resources go in /Game/UI. The editor doesn’t require resources be cooked, so that’s why it was working with the editor and not the game.
I’d been wondering what SWeakWidget is for a while now. The explanation I got was rather eye-opening and much broader in scope/application than just Slate. I did my best to apply it to the context of the Hello Slate tutorial (@dmacesic check it out on the wiki it has code examples), hopefully I can get some confirmation if my understanding of SWeakWidget within the context of Hello Slate is correct, anyone who works with UE4 should look into it (unless you’re already a Shared Vs. Weak pointer pro).
@anonymous_user_188e977a could you answer dmacesic question here ? I think there are several people who would like to know how to get widgets to display in Editor viewpoint without launching, me being one of them
Hey, thanks for the offer, but I agree that info should be shared here or on the wiki. For the moment I am getting by without Slate, but a complete example of the following is of interest to me:
How start a project that is a Slate Application, but with an Unreal viewport (e.g. like the actual Unreal Editor, but that is easier to understand, without the bloat). Maybe something like the SlateViewer, but with a viewport and blueprint support
How to make a menu in-game (MenuBar). Where is it created, how to have callbacks