O'Reilly logo

Unreal Engine 4 Scripting with C++ Cookbook by Stephen Whittle, William Sherif

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. Create a new class header in your project. Name the file "CookbookStyle.h".
  2. 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;
    };

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required