So far in this chapter, we've been creating UI elements that use the default visual representation. This recipe shows you how to create a Style in C++ that can be used as a common look-and-feel across your whole project.
Create a new class header in your project. Name the file
"CookbookStyle.h"
.Add the following code to the file:
#pragma once #include "SlateBasics.h" #include "SlateExtras.h" classFCookbookStyle { public: static void Initialize(); static void Shutdown(); static void ReloadTextures(); staticconstISlateStyle& Get(); staticFNameGetStyleSetName(); private: staticTSharedRef<class FSlateStyleSet> Create(); private: staticTSharedPtr<class FSlateStyleSet>CookbookStyleInstance; };
Create a corresponding implementation cpp file for this class, and add the following code to it:
#include "UE4Cookbook.h" #include "CookbookStyle.h" #include "SlateGameResources.h" TSharedPtr<FSlateStyleSet>FCookbookStyle...