Unreal Engine 4
Scripting with C++
Cookbook
Get the best out of your games by scripting them
using UE4
William Sherif
Stephen Whittle
Cookbook
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2016 Production reference: 1171016 Published by Packt Publishing Ltd. Livery Place
35 Livery Street
Birmingham B3 2PB, UK. ISBN 978-1-78588-554-9
Credits
Authors William Sherif Stephen Whittle Reviewer John Doran Commissioning Editor Amarabha Banerjee Acquisition Editor Smeet ThakkarContent Development Editor Prashanth G Technical Editor Sunith Shetty Copy Editor Sonia Mathur Project Coordinator Ulhas Kambali Proofreader Safis Editing Indexer Hemangini Bari Graphics Jason Monteiro Abhinash Sahu Production Coordinator Melwyn Dsa Cover Work Melwyn Dsa
About the Authors
William
Sherif
is a C++ programmer with more than eight years of experience in the programming world, ranging from game programming to web programming. He also worked as a university course instructor (sessional) for seven years. Additionally, he released several apps on the iTunes store, including Strum and MARSHALL OF THE ELITE SQUADRON. In the past, he has won acclaim for delivering course material in an easy-to-understand manner.Stephen
Whittle
is a game developer and educator with nearly 10 years of development experience, most of which has been done using Unreal Engine. He is a community contributor to the engine, with features or bug fixes included in almost every major version of the engine since its public release.I'd like to thank God; my partner, Nichelle; and my family and colleagues for their constant support while I wrote this book. Epic Games, in particular Mike Fricker and Alex Paschall, have also provided invaluable assistance.
About the Reviewer
John Doran
is a technical game designer who has been creating games for over 10 years. He has worked on an assortment of games in teams from just himself to over 70 in student, mod, and professional projects in different roles from game designer to lead UI programmer. He previously worked at LucasArts on Star Wars 1313 as a game designer. He later graduated from DigiPen Institute of Technology in Redmond, WA, with a bachelor of science in game design.In addition to working at DigiPen Game Studios, John is currently a part of DigiPen's research and development branch in Singapore. He is also the lead instructor of the DigiPen-Ubisoft campus game programming program, instructing graduate-level students in an intensive, advanced game-programming curriculum. He also tutors and assists students on various subjects, including C#, C++, Unreal, Unity, and game design.
He has authored Unity 5.x Game Development Blueprints, Unreal Engine Game Development Cookbook, Building an FPS Game in Unity, Unity Game Development Blueprints, Getting Started with UDK, UDK Game Development, Mastering UDK Game Development, and coauthored UDK iOS Game Development Beginner's Guide, all by Packt Publishing. You can find more about him at http://johnpdoran.com.
www.PacktPub.com
eBooks, discount offers, and more
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
[email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Why subscribe?
f Fully searchable across every book published by Packt f Copy and paste, print, and bookmark content
Table of Contents
Preface vii
Chapter 1: UE4 Development Tools
1
Introduction 2
Installing Visual Studio 2
Creating and building your first C++ project in Visual Studio 4 Changing the code font and color in Visual Studio 8 Extension – changing the color theme in Visual Studio 11 Formatting your code (Autocomplete settings) in Visual Studio 15
Shortcut keys in Visual Studio 17
Extended mouse usage in Visual Studio 19
UE4 – installation 19
UE4 – first project 21
UE4 – creating your first level 22
UE4 – logging with UE_LOG 23
UE4 – making an FString from FStrings and other variables 25 Project management on GitHub – getting your Source Control 26 Project management on GitHub – using the Issue Tracker 28 Project management on VisualStudio.com – managing the tasks
in your project 31
Project management on VisualStudio.com – constructing user stories
and tasks 34
Chapter 2: Creating Classes
39
Introduction 40
Making a UCLASS – deriving from UObject 40
Instantiating UObject-derived classes (ConstructObject < >
and NewObject < >) 53
Destroying UObject-derived classes 55
Creating a USTRUCT 56
Creating a UENUM( ) 58
Creating a UFUNCTION 58
Chapter 3: Memory Management and Smart Pointers
61
Introduction 62 Unmanaged memory – using malloc( )/free( ) 62
Unmanaged memory – using new/delete 64
Managed memory – using NewObject< > and ConstructObject< > 65
Managed memory – deallocating memory 67
Managed memory – smart pointers (TSharedPtr, TWeakPtr, TAutoPtr)
to track an object 68
Using TScopedPointer to track an object 69
Unreal's garbage collection system and UPROPERTY( ) 70
Forcing garbage collection 71
Breakpoints and stepping through code 71
Finding bugs and using call stacks 73
Using the Profiler to identify hot spots 74
Chapter 4: Actors and Components
77
Introduction 77
Creating a custom Actor in C++ 78
Instantiating an Actor using SpawnActor 82
Destroying an Actor using Destroy and a Timer 85 Destroying an Actor after a delay using SetLifeSpan 86 Implementing the Actor functionality by composition 87 Loading assets into components using FObjectFinder 89 Implementing the Actor functionality by inheritance 92 Attaching components to create a hierarchy 95
Creating a custom Actor Component 99
Creating a custom Scene Component 102
Creating a custom Primitive Component 106
Creating an InventoryComponent for an RPG 114
Creating an OrbitingMovement Component 125
Creating a building that spawns units 129
Chapter 5: Handling Events and Delegates
137
Handling events implemented via virtual functions 137 Creating a delegate that is bound to a UFUNCTION 140
Table of Contents Creating a delegate that takes input parameters 144 Passing payload data with a delegate binding 146
Creating a multicast delegate 148
Creating a custom Event 150
Creating a Time of Day handler 153
Creating a respawning pickup for an First Person Shooter 157
Chapter 6: Input and Collision
163
Introduction 163 Axis Mappings – keyboard, mouse and gamepad directional input
for an FPS character 164
Axis Mappings – normalized input 166
Action Mappings – one button responses for an FPS character 168 Adding Axis and Action Mappings from C++ 169
Mouse UI input handling 171
UMG keyboard UI shortcut keys 172
Collision – letting objects pass through one another using Ignore 173 Collision – picking up objects using Overlap 175 Collision – preventing interpenetration using Block 178
Chapter 7: Communication between Classes and Interfaces
181
Introduction 182
Creating a UInterface 182
Implementing a UInterface on an object 184
Checking if a class implements a UInterface 185 Casting to a UInterface implemented in native code 186 Calling native UInterface functions from C++ 189
Inheriting UInterface from one another 194
Overriding UInterface functions in C++ 198
Exposing UInterface methods to Blueprint from a native base class 202 Implementing UInterface functions in Blueprint 205 Creating C++ UInterface function implementations that can be
overridden in Blueprint 208
Calling Blueprint-defined interface functions from C++ 211 Implementing a simple interaction system with UInterfaces 216
Chapter 8: Integrating C++ and the Unreal Editor
225
Introduction 226 Using a class or struct as a blueprint variable 226 Creating classes or structs that can be subclassed in Blueprint 230
Creating C++ enums that can be used in Blueprint 249 Editing class properties in different places in the editor 256 Making properties accessible in the Blueprint editor graph 258 Responding to property – changed events from the editor 260 Implementing a native code Construction Script 263
Creating a new editor module 266
Creating new toolbar buttons 270
Creating new menu entries 278
Creating a new editor window 280
Creating a new Asset type 283
Creating custom context menu entries for Assets 287
Creating new console commands 294
Creating a new graph pin visualizer for Blueprint 300 Inspecting types with custom Details panels 306
Chapter 9: User Interfaces – UI and UMG
311
Introduction 311
Drawing using Canvas 312
Adding Slate Widgets to the screen 315
Creating screen size-aware scaling for the UI 319 Displaying and hiding a sheet of UMG elements in-game 325 Attaching function calls to Slate events 328 Use Data Binding with Unreal Motion Graphics 332 Controlling widget appearance with Styles 336
Create a custom SWidget/UWidget 343
Chapter 10: AI for Controlling NPCs
353
Introduction 353
Laying down a Navigation Mesh 354
Following behavior 354
Connecting a Behavior Tree to a Character 356
Constructing Task nodes 360
Using Decorators for conditions 361
Using periodic services 363
Using Composite nodes – Selectors, Sequences, and Simple Parallel 364
AI for a Melee Attacker 365
Chapter 11: Custom Materials and Shaders
367
Introduction 367
Modifying color using a basic Material 369
Modifying position using a Material 373
Shader code via Custom node 374
Table of Contents Shader parameters and Material instances 379 Glimmer 380
Leaves and Wind 382
Reflectance dependent on the viewing angle 384
Randomness – Perlin noise 385
Shading a Landscape 386
Chapter 12: Working with UE4 APIs
389
Introduction 390 Core/Logging API – Defining a custom log category 391 Core/Logging API – FMessageLog to write messages
to the Message Log 393
Core/Math API – Rotation using FRotator 395
Core/Math API – Rotation using FQuat 396
Core/Math API – Rotation using FRotationMatrix to have one
object face another 398
Landscape API – Landscape generation with Perlin noise 400 Foliage API – Adding trees procedurally to your level 404 Landscape and Foliage API – Map generation using Landscape
and Foliage APIs 406
GameplayAbilities API – Triggering an actor's gameplay abilities
with game controls 408
GameplayAbilities API – Implementing stats with UAttributeSet 413 GameplayAbilities API – Implementing buffs with GameplayEffect 415 GameplayTags API – Attaching GameplayTags to an Actor 417 GameplayTasks API – Making things happen with GameplayTasks 419
HTTP API – Web request 421
HTTP API – Progress bars 424
Preface
Unreal Engine 4 (UE4) is a complete suite of game development tools made by game developers for game developers. With more than 80 practical recipes, this book is a guide that showcases techniques to use the power of C++ scripting while developing games with UE4. We will start by adding and editing C++ classes from within the Unreal Editor. Then we will delve into one of Unreal's primary strengths—the ability for designers to customize programmer-developed actors and components. This will help you understand the benefits of when and how to use C++ as a scripting tool. With a blend of task-oriented recipes, this book will provide actionable information about scripting games with UE4 and manipulating the game and the development environment using C++. Toward the end of this book, you will be empowered to become a top-notch developer with UE4 using C++ as the scripting language.
What this book covers
Chapter 1, UE4 Development Tools, outlines basic recipes to get you started with UE4 game development and the basic tools used to create the code that makes your game.
Chapter 2, Creating Classes, focuses on how to create C++ classes and structs that integrate well with the UE4 Blueprints Editor. These classes will be graduated versions of regular C++ classes called UCLASSES.
Chapter 3, Memory Management and Smart Pointers, takes the reader through using all three types of pointer and mentions some common pitfalls regarding automatic garbage collection. This chapter also shows readers how to use Visual Studio or XCode to interpret crashes or confirm that the functionality is implemented correctly.
Chapter 4, Actors and Components, deals with creating custom actors and components, what purpose each serves, and how they work together.
Chapter 6, Input and Collision, shows how to connect user input to C++ functions and how to handle collisions in C++ from UE4. It will also provide default handling of game events such as user input and collision, allowing designers to override when necessary, using Blueprint. Chapter 7, Communication between Classes and Interfaces, shows you how to write your own UInterfaces, and demonstrates how to take advantage of them within C++ to minimize class coupling and help keep your code clean.
Chapter 8, Integrating C++ and the Unreal Editor, shows you how to customize the editor by creating custom Blueprint and animation nodes from scratch. We will also implement custom editor windows and custom detail panels to inspect types created by users.
Chapter 9, User Interfaces – UI and UMG, demonstrates that displaying feedback to the player is one of the most important elements within game design, and this will usually involve some sort of HUD, or at least menus, within your game.
Chapter 10, AI for Controlling NPCs, covers recipes to control your NPC characters with a bit of Artificial Intelligence (AI).
Chapter 11, Custom Materials and Shaders, talks about creating custom materials and audio graph nodes used in the UE4 editor.
Chapter 12, Working with UE4 APIs, explains that the application programming interface (API) is the way in which you, as the programmer, can instruct the engine (and so the PC) on what to do. Each module has an API for it. To use an API, there is a very important linkage step where you must list all APIs that you will use in your build in ProjectName.Build.cs file.
What you need for this book
Creating a game is an elaborate task that will require a combination of assets and code. To create assets and code, we'll need some pretty advanced tools, including art tools, sound tools, level-editing tools, and code-editing tools. Assets include any visual artwork (2D sprites, 3D models), audio (music and sound effects), and game levels. To perform that, we'll set up a C++ coding environment to build our UE4 applications. We'll download Visual Studio 2015, install it, and set it up for UE4 C++ coding. (Visual Studio is an essential package for code editing when editing the C++ code for your UE4 game.)
Who this book is for
This book is intended for game developers who understand the fundamentals of game design and C++ and would like to incorporate native code into the games they make with Unreal. They will be programmers who want to extend the engine or implement systems and actors that allow designers control and flexibility when building levels.
Sections
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
Getting ready
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
How to do it…
This section contains the steps required to follow the recipe.
How it works…
This section usually consists of a detailed explanation of what happened in the previous section.
There's more…
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
See also
This section provides helpful links to other useful information for the recipe.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The parameters passed to the UPROPERTY() macro specify a couple of important pieces of information regarding the variable."
A block of code is set as follows:
#include<stdio.h>
int main() {
puts("Welcome to Visual Studio 2015 Community Edition!"); }
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
int intVar = 5;
float floatVar = 3.7f;
FString fstringVar = "an fstring variable";
UE_LOG(LogTemp, Warning, TEXT("Text, %d %f %s"), intVar, floatVar, *fstringVar );
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "After you select the tools you'd like to add on to Visual Studio, click the Next button."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book— what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for this book from your account at http:// www.packtpub.com. If you purchased this book elsewhere, you can visit http://www. packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
1. Log in or register to our website using your e-mail address and password. 2. Hover the mouse pointer on the SUPPORT tab at the top.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box.
5. Select the book for which you're looking to download the code files. 6. Choose from the drop-down menu where you purchased this book from. 7. Click on Code Download.
You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account. Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
f WinRAR / 7-Zip for Windows f Zipeg / iZip / UnRarX for Mac f 7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/ PacktPublishing/Unreal-Engine-4-Scripting-with-CPlusPlus-Cookbook. We also have other code bundles from our rich catalog of books and videos available at
Downloading the color images of this book
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/ downloads/UnrealEngine4ScriptingwithC_Cookbook_ColorImages.pdf.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata,
selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/ content/support and enter the name of the book in the search field. The required
information will appear under the Errata section.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at questions@ packtpub.com, and we will do our best to address the problem.
UE4 Development Tools
In this chapter, we will outline basic recipes for getting started in UE4 game development, and the basic tools that we use for creating the code that makes your game. This will include the following recipes:
f Installing Visual Studio
f Creating and building your first C++ project in Visual Studio f Changing the code font and color in Visual Studio
f Extension – changing the color theme in Visual Studio f Formatting your code (Autocomplete settings) in Visual Studio f Shortcut keys in Visual Studio
f Extended mouse usage in Visual Studio f UE4 – installation
f UE4 – first project
f UE4 – creating your first level f UE4 – logging with UE_LOG
f UE4 – making an FString from FStrings and other variables
f Project management on GitHub – getting your Source Control f Project management on GitHub – using the Issue Tracker
f Project management on VisualStudio.com – managing the tasks in your project f Project management on VisualStudio.com – constructing user stories and tasks
Introduction
Creating a game is an elaborate task that will require a combination of assets and code. To create assets and code, we'll need some pretty advanced tools including art tools, sound tools, level editing tools, and code editing tools. In this chapter, we'll discuss finding suitable tools for asset creation and coding. Assets include any visual artwork (2D sprites, 3D models), audio (music and sound effects), and game levels. Code is the text (usually C++) that instructs the computer on how to tie these assets together to make a game world and level, and how to make that game world "play." There are dozens of very good tools for each task; we will explore a couple of each, and make some recommendations. Game editing tools, especially, are hefty programs that require a powerful CPU and lots of memory, and very good, ideal GPUs for good performance.
Protecting your assets and work is also a necessary practice. We'll explore and describe source control, which is how you back up your work on a remote server. An introduction to Unreal Engine 4 Programming is also included, along with exploring basic logging functions and library use. Significant planning is also required to get the tasks done, so we'll use a task-planner software package to do so.
Installing Visual Studio
Visual Studio is an essential package for code editing when editing the C++ code for your UE4 game.
Getting ready
We're going to set up a C++ coding environment to build our UE4 applications. We'll download Visual Studio 2015, install it, and set it up for UE4 C++ coding.
How to do it...
1. Begin by visiting https://www.visualstudio.com/en-us/products/ visual-studio-community-vs.aspx. Click on Download Community 2015. This downloads the ~200 KB loader/installer.
You can compare editions of Visual Studio at https://www.
visualstudio.com/en-us/products/compare-visual-studio-2015-products-vs.aspx. The Community Edition of Visual Studio is fully adequate for UE4 development purposes in this book.
2. Launch the installer, and select the components of Visual Studio 2015 that you want to add to your PC. Keep in mind that the more features you select, the larger your installation will be.
The preceding screenshot shows a recommended minimum installation, with Common Tools for Visual C++ 2015, Git for Windows, and GitHub Extension for Visual Studio all checked. We will use the Git for Windows features in a later section in this chapter.
3. After you have selected the tools you'd like to add onto Visual Studio, click the Next button. The installer tool will download the required components, and continue setup. Installation should take 20-40 minutes, depending on your option selections and connection speed.
4. After you download and install Visual Studio 2015, launch it. You will be presented with a Sign in dialog box.
You can Sign in with your Microsoft account (the one you use to sign into Windows 10), or Sign up for a new account. After you've signed in or signed up, you will be able to sign into Visual Studio itself. It may seem odd to sign into a desktop code editing program, but your sign-in will be used for source control commits to your repositories. On first signing in to Visual Studio, you can select (one time only) a unique URL for your source code repositories as hosted on Visualstudio.com.
How it works...
Visual Studio is an excellent editor, and you will have a fantastic time coding within it. In the next recipe, we'll discuss how to create and compile your own code.
Creating and building your first C++ project
in Visual Studio
Getting ready
In this recipe, we will identify how to create an actual executable running program from Visual Studio. We will do so by creating a project in Visual Studio to host, organize, and compile the code.
How to do it...
In Visual Studio, each group of code is contained within something called a Project. A Project is a buildable conglomerate of code and assets that produce either an executable (.exe
runnable) or a library (.lib, or .dll). A group of Projects can be collected together into
something called a Solution. Let's start by constructing a Visual Studio Solution and Project for a console application, followed by constructing a UE4 sample Project and Solution.
1. Open Visual Studio, and go to File | New | Project... 2. You will see a dialog as follows:
Select Win32 in the pane on the left-hand side. In the right-hand pane, hit Win32 Console Application. Name your project in the lower box, then hit OK.
3. In the next dialog box, we specify the properties of our console application. Read the first dialog box and simply click Next. Then, in the Application Settings dialog, choose the Console Application bullet, then under Additional options, choose Empty project. You can leave Security Development Lifecycle (SDL)
checks unchecked.
4. Once the application wizard completes, you will have created your first project. Both a Solution and a Project are created. To see these, you need Solution Explorer. To ensure that Solution Explorer is showing, go to View | Solution Explorer (or press Ctrl + Alt + L). Solution Explorer is a window that usually appears docked on the left-hand side or right-hand side of the main editor window as shown in the following screenshot:
Solution Explorer also displays all the files that are part of the project. Using Solution Explorer, we will also add a code file into the editor. Right click on your Project
FirstProject, and select Add | New Item…
5. In the next dialog, simply select C++ File (.cpp), and give the file any name you'd like. I called mine Main.cpp.
6. Once you have added the file, it will appear in Solution Explorer under your
FirstProject's source file filter. As your Project grows, more and more files are going to be added to your project. You can compile and run your first C++ program using the following text:
#include<stdio.h>
7. Press Ctrl + Shift + B to build the project, then Ctrl + F5 to run the project. 8. Your executable will be created, and you will see a small black window with the
results of your program's run:
How it works...
Building an executable involves translating your C++ code from text language to a binary file. Running the file runs your game program, which is just the code text that occurs in the
main() function between { and }.
There's more...
Build configurations are styles of build that we should discuss them here. There are at least two important build configurations you should know about: Debug and Release. The Build configuration selected is at the top of the editor, just below the toolbar in the default position.
Depending on which configuration you select, different compiler options are used. A Debug configuration typically includes extensive debug information in the build as well as turning off optimizations to speed up compilation. Release builds are often optimized (either for size or for speed), take a bit longer to build, and result in smaller or faster executables. Behavior stepping through with the debugger is often better in the Debug mode than the Release mode.
Changing the code font and color in Visual
Studio
Customizing the font and color in Visual Studio is not only extremely flexible, you will also find it very necessary if your monitor resolution is quite high or quite low.
Getting ready
Visual Studio is a highly customizable code editing tool. You might find the default fonts too small for your screen. You may want to change your code's font size and color. Or you may want to completely customize the coloration of keywords and the text background colors. The Fonts and Colors dialog box, which we'll show you how to use in this section, allows you to completely customize every aspect of the code editor's font and color.
How to do it...
1. From within Visual Studio, go to Tools | Options…
2. Select Environment | Fonts and Colors from the dialog that appears. It will look like the following screenshot:
3. Play around with the font and font size of Text Editor/Plain Text. Click OK on the dialog, and see the results in the code-text editor.
Text Editor/Plain Text describes the font and size used for all code text within the regular code editor. If you change the size of the font, the size changes for any text entered into the coding window (for all languages, including C, C++, C#, and others).
The color (foreground and background) is completely customizable for each item. Try this for the Text Editor/Keyword setting (affects all languages), or for C++-specific items, such as Text Editor/C++ Functions. Click OK, and you will see the changed color of the item reflected in the code editor.
You may also want to configure the font size of the Output Window—choose Show settings for => Output Window as seen in the following screenshot:
The Output Window is the little window at the bottom of the editor that displays build results and compiler errors.
You can't save-out (export) or bring in (import) your changes to the Fonts and Colors dialog. But you can use something called the Visual Studio
Theme Editor Extension, learn more refer to Extension – changing the color theme in Visual Studio to export and import customized color themes.
For this reason, you may want to avoid changing font colors from this dialog. You must use this dialog to change the font and font-size, however, for any setting (at the time of writing).
How it works...
The Fonts and Colors dialog simply changes the appearance of code in the text editor as well as for other windows such as the output window. It is very useful for making your coding environment more comfortable.
There's more...
Once you have customized your settings, you'll find that you may want to save your customized Fonts and Colors settings for others to use, or to put into another installation of Visual Studio, which you have on another machine. Unfortunately, by default, you won't be able to save-out your customized Fonts and Colors settings. You will need something called the Visual Studio Theme Editor extension to do so. We will explore this in the next recipe.
See also
f The Extension – changing the color theme in Visual Studio section describes how to
import and export color themes
Extension – changing the color theme in
Visual Studio
By default, you cannot save the changes you make to the font colors and background settings that you make in the Fonts and Colors dialog. To fix this issue, Visual Studio 2015 has a feature called Themes. If you go to Tools | Options | Environment | General, you can change the theme to one of the three pre-installed stock themes (Light, Blue, and Dark).
A different theme completely changes the look of Visual Studio—from the colors of the title bars to the background color of the text editor window.
You can also customize the theme of Visual Studio completely, but you'll need an extension to do so. Extensions are little programs that can be installed into Visual Studio to modify its behavior.
By default, your customized color settings cannot be saved or reloaded into another Visual Studio installation without the extension. With the extension, you will also be able to save your own color theme to share with others. You can also load the color settings made by another person or by yourself into a fresh copy of Visual Studio.
How to do it...
1. Go to Tools | Extensions and Updates…
2. From the dialog that appears, choose Online in the panel on the left-hand side. Start typing Theme Editor into the search box at the right. The Visual Studio 2015 Color Theme Editor dialog will pop up in your search results.
3. Click the small Download button in the top right-hand corner of the entry. Click through the installation dialog prompts, allowing the plugin to install. After installation, Visual Studio will prompt you to restart.
Alternatively, visit https://visualstudiogallery.msdn. microsoft.com/6f4b51b6-5c6b-4a81-9cb5-f2daa560430b and download/install the extension by double-clicking the .vsix that comes from your browser.
5. After restarting, go to Tools | Customize Colors to open the Color Themes editor page.
6. From the Color Themes dialog that appears, click on the little palette-shaped icon on the upper-right corner of the theme that you want to use as your base or starting theme (I've clicked on the palette for the Light theme here, as you can see in the following screenshot).
7. A copy of the theme will appear in the Custom Themes section in the lower part of the Color Themes window. Click on Edit Theme to modify the theme. When you are editing the theme, you can change everything from the font text color to the C++ keyword color.
8. The main area you are interested in is the C++ Text Editor section. To gain access to all the C++ Text Editor options, be sure to select the Show All Elements option at the top of the Theme Editor window, as shown in the following screenshot:
Be sure to select the Show All Elements option in the Theme Editor window to show C++-specific text editor settings. Otherwise, you'll be left with Chrome/GUI type modifications being possible only.
9. Note that, while most of the settings you are interested in will be under Text Editor | C/C++, some will not have that C++ subheading. For example, the setting for the main/plain text inside the editor window (for all languages) is under Text Editor | Plain Text (without the C++ subheading).
10. Select the theme to use from Tools | Options | Environment | General. Any new themes you have created will appear automatically in the drop-down menu.
How it works...
Once we load the plugin, it integrates into Visual Studio quite nicely. Exporting and uploading your themes to share with others is quite easy too.
Adding a theme to your Visual Studio installs it as an extension in Tools | Extensions and Updates…, To remove a theme, simply Uninstall its Extension.
Formatting your code (Autocomplete
settings) in Visual Studio
Code-writing formatting with Visual Studio is a pleasure. In this recipe, we'll discuss how to control the way Visual Studio lays out the text of your code.
Getting ready
Code has to be formatted correctly. You and your co-programmers will be able to better understand, grok, and keep your code bug-free if it is consistently formatted. This is why Visual Studio includes a number of auto-formatting tools inside the editor.
How to do it...
1. Go to Tools | Options | Text Editor | C/C++. This dialog displays a window that allows you to toggle Automatic brace completion.
Automatic brace completion is the feature where, when you type { , a corresponding
} is automatically typed for you. This feature may irk you if you don't like the text editor inserting characters for you unexpectedly.
You generally want Auto list members on, as that displays a nice dialog with the complete names of data members listed for you as soon as you start typing. This makes it easy to remember variable names, so you don't have to memorize them:
If you press Ctrl + Spacebar inside the code editor at any time, the auto list pops up.
2. Some more autocomplete behavior options are located under Text Editor | C/C++ | Formatting:
Autoformat section: Highlight a section of text and select Edit | Advanced | Format Selection (Ctrl + K, Ctrl + F).
How it works...
The default autocomplete and autoformat behaviors may irk you. You need to converse with your team on how you want your code formatted (spaces or tab indents, size of indent, and so on), and then configure your Visual Studio settings accordingly.
Shortcut keys in Visual Studio
Shortcut keys really save you time when coding. Knowing shortcut keys offhand is always good.
Getting ready
There are a number of shortcut keys that will make coding and project navigation much faster and more efficient for you. In this recipe, we describe how to use some of the common shortcut keys that will really enhance your coding speed.
How to do it...
The following are some very useful keyboard shortcuts for you to try:
1. Click on one page of the code, then click somewhere else, at least 10 lines of code away. Now press Ctrl + - [navigate backwards]. Navigation through different pages of source code (the last place you were at, and the place you are at now) is done by pressing Ctrl + - and Ctrl + Shift + - respectively.
Warping around in the text editor using Ctrl + -. The cursor will jump back to the last location it was in that is more than 10 lines of code away, even if the last location was in a separate file.
Say, for example, you're editing code in one place, and you want to go back to the place you've just been (or go back to the section in the code you came from). Simply press Ctrl + -, and that will warp you back to the location in the code you were at last. To warp forward to the location you were at before you pressed Ctrl + -, press Ctrl + Shift + -. To warp back, the previous location should be more than 10 lines away, or in a different file. These correspond to the Forward and Back menu buttons in the toolbar:
The Back and Forward navigation buttons in the toolbar, which correspond to the Ctrl + - and Ctrl + Shift + - shortcuts respectively.
2. Press Ctrl + W to highlight a single word.
3. Press and hold Ctrl + Shift + right arrow (or left arrow) (not Shift + right arrow) just to move to the right and left of the cursor, selecting entire words.
4. Press Ctrl + C to copy text, Ctrl + X to cut text, and Ctrl + V to paste text.
5. Clipboard ring: The clipboard ring is a kind of a reference to the fact that Visual Studio maintains a stack of the last copy operations. By pressing Ctrl + C, you push the text that you are copying into an effective stack. Pressing Ctrl + C a second time on different text pushes that text into the Clipboard Stack. For example, in the following diagram, we pressed Ctrl + C on the word cyclic first, then Ctrl + C on the word paste afterwards.
As you know, pressing Ctrl + V pastes the top item in the stack. Pressing Ctrl + Shift + V accesses a very long history of all the items ever copied in that session, that is, items underneath the top item in the stack. After you exhaust the list of items, the list wraps back to the top item in the stack. This is an odd feature, but you may find it useful occasionally.
6. Ctrl + M, Ctrl + M collapses a code section.
How it works...
Keyboard shortcuts allow you to speed up work in the code editor by reducing the number of mouse reaches that you have to perform in a coding session.
Extended mouse usage in Visual Studio
The mouse is a pretty handy tool for selecting text. In this section, we'll highlight how to use the mouse in an advanced way for quick edits to your code's text.
How to do it...
1. Hold down the Ctrl key while clicking to select an entire word.
2. Hold down the Alt key to select a box of text (Alt + Left Click + Drag).
You can then either cut, copy, or overwrite the box-shaped text area.
How it works...
Mouse clicking alone can be tedious, but with the help of Ctrl + Alt, it becomes quite cool. Try Alt + Left Click + Drag for selecting a row of text, then typing as well. The characters you type will be repeated in rows.
UE4 – installation
There are a number of steps to follow to install and configure UE4 properly. In this recipe, we'll walk through the correct installation and setup of the engine.
Getting ready
UE4 takes up quite a few GB of space, so you should have at least 20 GB or so free for the installation on the target drive.
How to do it...
1. Visit unrealengine.com and download it. Sign up for an account if required. 2. Run the installer for the Epic Games Launcher Program by double-clicking the
EpicGamesLauncherInstaller-x.x.x-xxx.msi installer. Install it in the default location.
3. Once the Epic Games Launcher program is installed, open it by double-clicking its icon on your desktop or in the Start menu.
4. Browse the start page and take a look around. Eventually, you will need to install an engine. Click on the large orange Install Engine button on the top-left side from the UE4 tab, as shown in the following image:
5. A pop-up dialog will show the components that can be installed. Select the
components you'd like to install. The recommendation is to begin by installing the first three components (Core Components, Starter Content, and Templates and Feature Packs). You can leave out the Editor symbols for debugging component if you will not be using it.
6. After the engine has installed, the Install Engine button will change to a Launch Engine button.
How it works...
The Epic Games Launcher is the program that you need to start up the engine itself. It keeps a copy of all your projects and libraries in the Library tab.
There's more...
Try downloading some of the free library packages in the Library | Vault section. For that, click the Library item on the left side, and scroll down until you see Vault, underneath My Projects.
UE4 – first project
Setting up a Project within UE4 takes a number of steps. It is important to get your options correct so that you can have the setup that you like, so carefully follow this recipe when constructing your first project.
Each project that you create within UE4 takes up at least 1 GB of space or so, so you should decide whether you want your created projects on the same target drive, or on an external or separate HDD.
How to do it...
1. From the Epic Games Launcher, click on the Launch Unreal Engine 4.11.2 button. Once you are inside the engine, an option to create a new project or load an existing one will presents itself.
2. Select the New Project tab.
3. Decide whether you will be using C++ to code your project, or Blueprints exclusively. 1. If using Blueprints exclusively, make your selection of a template to use from
the Blueprint tab.
2. If using C++ in addition to Blueprints to construct your project, select the project template to construct your project based on the C++ tab.
3. If you're not sure what template to base your code on, BASIC Code is an excellent starting point for any C++ project (or Blank for a Blueprint-exclusive project).
4. Take a look at the three icons that appear beneath the template listing. There are three options here to configure:
1. You can choose to target Desktop or Mobile applications.
2. You have an option to alter the quality settings (the picture of a plant with magic). But you probably don't need to alter these. The quality settings are reconfigurable under Engine | Engine Scalability Settings anyway.
3. The last option is whether to include Starter Content with the project or not. You can probably use the Starter Content package in your project. It has some excellent materials and textures available within it.
If you don't like the Starter Content package, try the packages in the UE4 Marketplace. There is some excellent free content there, including the GameTextures Material Pack.
5. Select the drive and folder in which you will save your project. Keep in mind that each project is roughly 1 GB in size, and you will need at least that much space on the destination drive.
6. Name your project. Preferably name it something unique and specific to what you are planning on creating.
7. Hit Create. Both the UE4 Editor and Visual Studio 2015 windows should pop up, enabling you to edit your project.
In the future, keep in mind that you can open the Visual Studio 2015 Solution via one of the two following methods:
f Via your local file explorer. Navigate to the root of where your project
is stored, and double-click on the ProjectName.sln file.
f From UE4, click on File | Open Visual Studio.
UE4 – creating your first level
Creating levels in UE4 is easy and facilitated by a great UI all around. In this recipe, we'll outline basic editor use and describe how to construct your first level once you have your first project launched.
Getting ready
Complete the previous recipe, UE4 – First Project. Once you have a project constructed, we can proceed with creating a level.
How to do it…
1. The default level that gets set up when you start a new project will contain some default geometry and scenery. You don't need to start with this starter stuff, however. If you don't want to build from it, you can delete it, or create a new level.
2. To create a new level, click File | New Level… and select to create a level with a background sky (Default), or without a background sky (Empty Level).
If you choose to create a level without a background sky, keep in mind that you must add a light to it to see the geometry you add to it effectively.
3. If you loaded the Starter Content on your project's creation (or some other content), then you can use the Content Browser to pull content into your level. Simply drag and drop instances of your content from the Content Browser into the level, save, and launch them.
4. Add some geometry to your level using the Modes panel (Window | Modes). Be sure to click on the picture of a light bulb and cube to access the placeable geometry. You can also add lights via the Modes tab by clicking on the Lights subtab on the left-hand side of the Modes tab.
The Modes panel contains two useful items for level construction: some sample geometry to add (cubes and spheres and the like) as well as a panel full of lights. Try these out and experiment to begin laying out your level.
Getting ready
When coding, we may sometimes want to send some debug information out to the UE log window. This is possible using the UE_LOG macro. Log messages are an extremely important and convenient way to keep track of information in your program as you are developing it.
How to do it...
1. In your code, enter a line of code using the form:
UE_LOG(LogTemp, Warning, TEXT("Some warning message") );
2. Turn on the Output Log inside the UE4 editor to see your log messages printed in that window as your program is running.
How it works...
The UE_LOG macro accepts a minimum of three parameters:
f The Log category (we used LogTemp here to denote a log message in a temporary
log)
f The Log level (we used a warning here to denote a log message printed in yellow
warning text)
f A string for the actual text of the log message itself
Do not forget the TEXT() macro around your log message text! It promotes the enclosed text to Unicode (it prepends an L) when the compiler is set to run with Unicode on.
UE_LOG also accepts a variable number of arguments, just like printf() from the C programming language.
int intVar = 5;
float floatVar = 3.7f;
FString fstringVar = "an fstring variable";
UE_LOG(LogTemp, Warning, TEXT("Text, %d %f %s"), intVar, floatVar, *fstringVar );
There will be an asterisk * just before FString variables when using UE_LOG to dereference the FString to a regular C-style TCHAR pointer.
TCHAR is usually defined as a variable type where, if Unicode is being used in the compile, the TCHAR resolves to wchar_t. If Unicode is off (compiler switch _UNICODE not defined), then TCHAR resolves to simply char.
Don't forget to clear your log messages after you no longer need them from the source!
UE4 – making an FString from FStrings and
other variables
When coding in UE4, you often want to construct a string from variables. This is pretty easy using the FString::Printf or FString::Format functions.
Getting ready
For this, you should have an existing project into which you can enter some UE4 C++ code. Putting variables into a string is possible via printing. It may be counterintuitive to print into a string, but you can't just concatenate variables together, and hope that they will automatically convert to string, as in some languages such as JavaScript.
How to do it…
1. Using FString::Printf():
1. Consider the variables you'd like printed into your string.
2. Open and take a look at a reference page of the printf format specifiers, such as http://en.cppreference.com/w/cpp/io/c/fprintf.
3. Try code such as the following:
FString name = "Tim"; int32 mana = 450;
FString string = FString::Printf( TEXT( "Name = %s Mana = %d" ), *name, mana );
Notice how the preceding code block uses the format specifiers precisely as the traditional printf function does. In the preceding example, we used %s to place a string in the formatted string, and %d to place an integer in the formatted string. Different format specifiers exist for different types of variables, and you should look them up on a site such as cppreference.com.
2. Using FString::Format(). Write code in the following form:
FString name = "Tim"; int32 mana = 450;
TArray< FStringFormatArg > args; args.Add( FStringFormatArg( name ) ); args.Add( FStringFormatArg( mana ) );
FString string = FString::Format( TEXT( "Name = {0} Mana = {1}" ), args );
UE_LOG( LogTemp, Warning, TEXT( "Your string: %s" ), *string );
With FString::Format(), instead of using correct format specifiers, we use simple integers and a TArray of FStringFormatArg instead. The FstringFormatArg
helps FString::Format() deduce the type of variable to put in the string.
Project management on GitHub – getting
your Source Control
A very important thing to do for your project as you're developing it is to generate a timeline history as you're working. To do so, you need to back up your source code periodically. A great tool for doing so is Git. Git allows you to park changes (commits) into a repository online on a remote server so that your code's development history is documented and preserved on that remote server. If your local copy gets damaged somehow, you can always recover from the online backups. This timeline-history of your codebase's development is called Source Control.
Getting ready
There are a couple of free services that offer online source backups. Some of the free alternatives for storing your data include:
f Visualstudio.com: limited/private sharing of your repository f github.com: unlimited public sharing of your repositories
Visualstudio.com is great for when you want some privacy for your project for free, while GitHub is great when you want to share your project with lots of users for free. Visualstudio. com also offers some very good workboarding and planning features, which we will use later in this text (GitHub also offers a competing Issue Tracker, which we'll discuss later on as well). The website you choose depends mostly on how you plan on sharing your code. In this text, we will use GitHub for source code storage, since we need to share our code with a large number of users (you!)
How to do it...
1. Sign up for a GitHub account at https://github.com. Sign into your GitHub account using the Team Explorer menu (View | Team Explorer).
2. Once you have the Team Explorer open, you can sign into your GitHub account using the button that appears in the Team Explorer window.
3. After you've signed in, you should gain the capability to Clone and Create repositories. These options will appear right underneath the GitHub menu in the Team Explorer.
4. From here, we want to create our first repository. Hit the Create button, and name your repository in the window that comes up.
When creating your project, take care to select the VisualStudio option from the .gitignore options menu. This will cause Git to ignore the Visual Studio-specific files that you don't want included in your repository, such as the Build and Release directories.
5. Now you have a repository! The repository is initialized on GitHub. We just have to put some code into it.
6. Open up the Epic Games Launcher, and create a project to put into the repository. 7. Open the C++ project in Visual Studio 2015, and right-click on Solution. Select Add
Solution to Source Control from the context menu that appears. The dialog that appears will ask whether you want to use Git or TFVC.
If you use Git for your source control, then you can host on either github.com or Visualstudio.com.
8. After you add Git Source Control to the project, take a look at Team Explorer again. From that window, you should enter a brief message, then click on the Commit button.
How it works...
Git repositories are important for backing up copies of your code and project files as your project evolves. There are many commands within Git to browse the project history (try the Git GUI tool), see what changes you've made since the last commit (git diff), or move
backward and forward through the Git history (git checkout commit-hash-id).
Project management on GitHub – using the
Issue Tracker
Keeping track of you project's progress, features, and bugs is extremely important. The GitHub Issue Tracker will enable you to do this.
Getting ready
Keeping track of your project's planned features and running issues is important. GitHub's Issue Tracker can be used to create lists of features you'd like to add to your project as well as bugs you need to fix at some time in the future.
How to do it...
1. To add an issue to your Issue Tracker, first select the repository that you'd like to edit by going to the front page of GitHub and selecting the Repositories tab:
2. From your repository's homepage, select the Issues tab under your repository. To add an issue to track, click the New Issue button in the lower-right corner of the screen, as seen in the following screenshot:
3. When adding your issue, it is good practice to detail it as much as possible. Including screenshots and diagrams in the features or bugs you post is highly recommended, as it documents the issue much better, and parks important information and a good description into your Issue Tracker. Dragging and dropping images into the text editor window automatically uploads a copy of the image to GitHub's own cloud server, and the image will appear inline in the issue, as shown in the following screenshot:
4. The box into which you enter the description of your bug or feature supports
Markdown. Markdown is a simplified HTML-like markup language that lets you quickly write HTML-like syntax with ease. Examples of some markdown syntax are as follows:
# headings ## sub-headings ### sub-sub-headings
_italics_, __bold__, ___bold-italics___ [hyperlinks](http://towebsites.com/)
- sub bullets - sub sub bullets
>quotations
If you want to learn more about Markdown's syntax, check out https://daringfireball.net/projects/ markdown/syntax.
5. You can further mark the issue as either a bug, enhancement (feature), or any other label you like. Customizing labels is possible via the Issues | Labels link:
6. From there, you can edit, change the color of, or delete your labels. I deleted all the stock labels, and replaced the word enhancement with feature, as seen in the following two screenshots:
7. Once you've fully customized your labels, your GitHub Issue Tracker is much easier to navigate. Prioritize issues by tagging with the appropriate labels.
How it works...
GitHub's Issue Tracker is a fantastic way to track bugs and features in your project. Using it not only organizes your workflow, but also maintains an excellent history of the work done on the project.
See also
f You should also check out the Wiki feature, which allows you to document your
source code
Project management on VisualStudio.com –
managing the tasks in your project
High-level management of your project is usually done using a planning tool. GitHub's Issue Tracker may meet your needs, but if you're looking for more, Microsoft's Visual Studio Team Services offers planning tools for Scrum and Kanban style programming assignment of tasks (Features, Bugs, and so on).
Using this tool is a great way to organize your tasks to make sure things get done on time, and to get used to an industrial-standard workflow. When you sign up for Visual Studio's Community Edition during setup, your account includes free use of these tools.
How to do it...
In this section, we'll describe how to use the Workboard feature on Visualstudio.com to plan a few simple tasks.
1. To create your own project Workboard, go to your account at Visualstudio.com. Log in, and then select the Overview tab. Under Recent projects & teams title, select the New link.
2. Add a Project name and Description to your project. After you've named your project (I've named mine Workboards), click on Create project. You will wait a second or two for project creation to complete, then hit the Navigate to project button in the next dialog.
3. The next screen that is shown allows you to navigate to the Workboards area. Click on Manage Work.
4. The Manage Work screen is a Kanban styled (read: prioritized) task queue of things to do in your project. You can hit the New item button to add new items to your list of things to do.
As soon as you add something to your to-do list, it is called being part of your backlog. In Kanban, you're always behind! If you're a manager, you never want an empty backlog.
How it works…
Each item on your Board's backlog is called a User Story. A User Story is an Agile software development term, and each User Story is supposed to describe a need of a particular end user. For example, in the preceding User Story, the need is to have visual graphics, and the User Story describes that graphics (sprites) must be created to satisfy this user requirement. User stories will often have a specific format:
As a <someone>, I want <this> so that <advantage>.
For example:
As a <player of the game> I want to <reorganize items> so that I can <set hotkeys to slots that I desire>.
On the Workboard, you'll have a bunch of user stories. I have placed a few user stories earlier so we can play with them.
Once your board is filled with user stories, they will all sit in the New vertical column. As you start work on or make progress on a particular User Story, you can drag it horizontally from New to Active, then finally to Resolved and Closed when the User Story is complete.
Project management on VisualStudio.com –
constructing user stories and tasks
From the Scrum point of view, a User Story is grouping of tasks that need to be done. A group of user stories can be collected into a Feature, and a group of Features can be gathered together into what is called an Epic. VisualStudio.com organizes User Story creation very well so that it's easy to construct and plan the completion of any particular task (user story). In this recipe, we'll describe how to assemble and put together user stories.
Getting ready
Every item entered into VisualStudio.com's project management suite should always be a feature that somebody wants to be in the software. User story creation is a fun, easy, and exciting way to group together and mete out bunches of tasks to your programmers as work to be done. Log in to your VisualStudio.com account now, edit one of your projects, and begin using this feature.
How to do it…
1. From the VisualStudio.com Team Services landing page, navigate to the project into which you want to enter some new work to be done. All of your Projects can be found if you click on Browse under the Recent projects & teams heading.
2. Select the project that you want to work with and hit Navigate.
3. Tasks inside Visualstudio.com take place inside of one of the three categories of super task:
User Story Features Epics
User Stories, Features, and Epics are just organizational units for work. An Epic contains many Features. A Feature contains many User Stories, and a User Story contains many Tasks.
By default, Epics are not shown. You can display Epics by going to Settings (the gear icon on the right side of the screen). Then navigate to General | Backlogs. Under the section that says See only the backlogs your team manages, select to display all three flavors of Backlog: Epics, Features, and Stories.
4. There are now four navigation steps to perform before you can enter your first task (User Story) into the Backlog:
1. From the menu bar at the top, select WORK.
2. Then, in the submenu that appears on the WORK page, select Backlogs. 3. On the sidebar that appears, click on Stories.
4. From the panel on the right-hand side, select Board.
Backlog is the set of User Stories and Tasks that we have yet to complete. You might think, "Are brand new tasks really entered into a Backlog?" That's right! You're already behind! The implications of Scrum's terminology seem to imply "overflowing with work".
5. From the panel on the right-hand side, hit New item, and fill in the text for your new User Story item.
6. Click on the text of the User Story card, and fill in the fields for Assignee, the Iteration that it's a part of, Description, tags, and any other fields of the Details tab that you want to explore.
7. Next we break down the overall User Story into a series of achievable tasks. Hover over your new User Story item until the ellipsis (three dots…) appears. Click on the ellipsis, and select + Add Task.
8. List the details of completing the User Story in the series of Tasks. 9. Assign each Task to:
An Assignee An Iteration
Simply put, an Iteration is really just a time period. At the end of each iteration, you should have a deliverable, testable piece of software completed. Iteration is a time period that refers to producing yet another version of your amazing software (for testing and possible release).
10. Continue adding Tasks to the project as the project develops features to complete and bugs to fix.
How it works…
Epics contain a number of Features. Features contain a number of User Stories, and User Stories contain a number of Tasks and Tests.
All of these items are assignable to a User (an actual human), and to an Iteration (time period), for both assigning responsibility and scheduling a task. Once these are assigned, the task should appear in the Queries tab.
Detailed steps to download the code bundle are mentioned in the Preface of this book. Please have a look.
The code bundle for the book is also hosted on GitHub at https:// github.com/PacktPublishing/Unreal-Engine-4-Scripting-with-CPlusPlus-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/ PacktPublishing/. Check them out!
2
Creating Classes
This chapter focuses on how to create C++ classes and structs that integrate well with the UE4 Blueprints editor. These classes are graduated versions of the regular C++ classes, and are called UCLASS.
A UCLASS is just a C++ class with a whole lot of UE4 macro decoration on top. The macros generate additional C++ header code that enables integration with the UE4 Editor itself.
Using UCLASS is a great practice. The UCLASS macro, if configured correctly, can possibly make your UCLASS Blueprintable. The advantage of making your UCLASS Blueprintable is that it can enable your custom C++ objects to have Blueprints visually editable properties (UPROPERTY) with handy UI widgets such as text fields, sliders, and model selection boxes. You can also have functions (UFUNCTION) that are callable from within a Blueprints diagram. Both of these are shown in the following screenshots: