Adding Slate Styles(Why every one is using such a complex method)

Hi,

All of the guides I read regarding adding slate style follow a really complex method of creating a style class and linking them with game module etc steps like that.

I tried something much easier and was successful but why is no one using this method? Does it create leaks or something of that sort?

I just created a

UPROPERTY(EditAnywhere, Category = Appearance)
	FButtonStyle MenuButtonStyle;

Inside my HUD class. My HUD class and slate class were already linked with pointers so what I did was

				SNew(SButton)
				.ButtonStyle(&BallHUD->MenuButtonStyle)
				.Text(FText::FromString("Jump"))
				.OnClicked(this, &SGameWidget::JumpClicked)

and it worked. But it surprises me why no one uses this method.

Well, basically you can write a whole game in one file, but you don’t do it, do you? :wink:

It’s just a matter of project structure. Of course, if you have just a couple of windows you can set everything in HUD class. Download Shooter game and look at its interface, how complex it is. And how well-ordered it is at the same time. It’s so easy to read and understand it. Not only code should be structured but your editor assets too. It would be much better if your WidgetStyle assets were in dedicated folder all named and ordered. Easy to edit, easy to debug. Easy to work with. What if your designer doesn’t know C++ and wants just to add another style based on some template you did? Should he ask programmers to give up their current task and add another property to HUD class? This totally ruins whole division of labor principle.

Well its a small game so that wont be needed. I some times add actor components do decrease complexity of things. I thing that would help a lot.

Of course it’s all for you to decide. But tutorials are universal. That’s why they use methods which are good for projects of any scale.