would someone, who understands slate in c++, help me getting started?
I watched some Tutorials and read Ramas Tutorials, as well as the ones on minalien.com.
But my understanding is a bit lacking.
I know how it is structured, with the containers that hold new containers and so on (it’s similar to Unitys system), but i can’t solve simple questions on my own if i want to create something aside the tutorials.
I know that i can definine anchorpoints with the H and VAlign. But where do i say where the main container is located? All tutorials place the containers at the top, or in some corners, but what if i want to place it in the center?
I got one main container that has the size of the viewport, but if i create a horizontal box in this now, it will be aligned to top/bottom or what ever, but how can i place it in the middle a bit to the left?
I searched the documentation but the V/HAlign seems to by an enum, not something to set exactly at some values.
And another question is, if i have an int array, how can i add multiple instances of button widget based on the entries (so if there is a -1, nothing should be “drawn”). I can give the widget the array with params, thats what i learned from a tutorial and i can display names etc, but can i make a for loop with an if that checks if the values is not -1 and than call the “draw” of the simple button?
And how could i place 9 buttons in a 3x3 raster?
So many simple questions that i can’t solve by my own, because slate seems so complicated even with these simple tasks. I know we have UMG in 4.4, but it can’t be used for my things right now and i would like to be free from waiting for updates on UMG.
What would help me the most would be simple code examples how to setup the asked things.
I hope that is not too much asked, but i really want to learn slate!
I created a simple Widget that should display an image that i set on my Character.
Here is my Widget.h;
class SMyUIWidget : public SCompoundWidget
/*See private declaration of OwnerHUD below.*/
SLATE_ARGUMENT(TWeakObjectPtr<class AMyHUD>, OwnerHUD)
SLATE_ARGUMENT(TWeakObjectPtr<class AMyCharacter>, OwnedCharacter)
/////Needed for every widget
/////Builds this widget and any of it's children
void Construct(const FArguments& InArgs);
/////Pointer to our parent HUD
/////To make sure HUD's lifetime is controlled elsewhere, use "weak" ptr.
/////HUD has "strong" pointer to Widget,
/////circular ownership would prevent/break self-destruction of hud/widget (cause memory leak).
TWeakObjectPtr<class AMyHUD> OwnerHUD;
TWeakObjectPtr<class AMyCharacter> OwnedCharacter;
const struct FGlobalStyle* MenuStyle;
This my SMyUIWidget.cpp
void SMyUIWidget::Construct(const FArguments& InArgs)
OwnerHUD = InArgs._OwnerHUD;
OwnedCharacter = InArgs._OwnedCharacter;
MenuStyle = &FMenuStyles::Get().GetWidgetStyle<FGlobalStyle>("Global");
const FSlateBrush *icon = &OwnedCharacter->ItemPicture;
/////If the code below doesn't look like C++ to you it's because it (sort-of) isn't,
/////Slate makes extensive use of the C++ Prerocessor(macros) and operator overloading,
/////Epic is trying to make our lives easier, look-up the macro/operator definitions to see why.
On my character i have included Slate.h and created a SlateBrush that is editable in a blueprint. That is working but if i start the game, i get this error:
First-chance exception at 0x000007FED4A63A76 (UE4Editor-Slate.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x00000000000004B8.
Unhandled exception at 0x000007FED4A63A76 (UE4Editor-Slate.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x00000000000004B8.
Why? Simply why?
I have also tried to use the Character brush directly instead of using it for the icon Variable, but the error persists.