Controlling widget appearance with Styles
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.
How to do it...
- 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; };
Get Unreal Engine 4 Scripting with C++ Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.