gdc europe 2014: unreal engine 4 for programmers - lessons learned & things to come
TRANSCRIPT
![Page 2: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/2.jpg)
Then…
• “We ain’t gonna need it”
• Fixed, rigid feature set
• First Person Shooter centric
• Programmer centric
• Closed source
• Monolithic, aged code base
• Secret development schedule
• PC & console focused
• Millions of $ studio licenses
Now…
• “You might need it”
• Plug-ins and customizable tools
• Game type agnostic
• Artist & game designer friendly
• Public source
• Modular code base, largely rewritten
• Public feature voting on trello.com
• Seamless multi-platform development
• $19/month subscription
Unreal Engine in 2014
![Page 3: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/3.jpg)
Unreal Engine in 2014
![Page 4: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/4.jpg)
Engine Overview
![Page 5: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/5.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
Root Directory
• /Engine – All code, content & configuration for the Engine
• /MyProject – All files for the game project ‘MyProject’
• /Templates – Templates for creating new projects
Inside the /Engine and Project Directories
• /Binaries – Executables & DLLs for the Engine
• /Build – Files needed for building the Engine
• /Config – Configuration files
• /Content – Shared Engine content
• /DerivedDataCache – Cached content data files (Engine only)
• /Intermediate – Temporary build products (Engine only)
• /Plugins – Shared and project specific plug-ins
• /Saved – Autosaves, local configs, screenshots, etc.
• /Source – Source code for all the things!
![Page 6: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/6.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
INI Files
• Hold class default properties
• Will be loaded into CDOs on startup
• Organized in a hierarchy
• Higher INIs override lower ones
• Organized in sections
• Key-value pairs within sections
• Important ones exposed in Editor UI
• Low-level access with FConfig
![Page 7: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/7.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
INI Files
• Hold class default properties
• Will be loaded into CDOs on startup
• Organized in a hierarchy
• Higher INIs override lower ones
• Organized in sections
• Key-value pairs within sections
• Important ones exposed in Editor UI
• Low-level access with FConfigClass Constructor
BaseXXX.ini
DefaultXXX.ini
XXX.ini
![Page 8: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/8.jpg)
Editor & Project Settings
![Page 9: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/9.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
Modularity Promotes
• Reusability
• Extensibility
• Maintainability
• Decoupling
• Efficiency
Monolithic builds are
still possible though!
![Page 10: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/10.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
Module Types
• Developer – Used by Editor & Programs, not Games
• Editor – Used by Unreal Editor only
• Runtime – Used by Editor, Games & Programs
• ThirdParty – External code from other companies
• Plugins – Extensions for Editor, Games, or both
• Programs – Standalone applications & tools
Module Dependency Rules
• Runtime modules must not have dependencies to Editor or Developer modules
• Plug-in modules must not have dependencies to other plug-ins
![Page 11: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/11.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
Module TypeUnrealEd App Game
Runtime √ √ √
ThirdParty √ √ √
Plugins √ √ √
Developer √ √ X
Editor √ X X
Module usage across different types of applications
![Page 12: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/12.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
Important Modules for Beginners
• Core – Fundamental core types & functions
• CoreUObject – Implements the UObject sub-system
• Engine – Game classes & engine framework
• OnlineSubsystem – Online & social networking features
• Slate – Widget library & high-level UI features
![Page 13: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/13.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
Interesting Modules for Advanced Programmers
• DesktopPlatform – Useful APIs for Windows, Mac & Linux
• DetailCustomizations – Editor’s Details panel customizations
• Launch – Main loop classes & functions
• Messaging – Message passing sub-system
• Sockets – Network socket implementations
• Settings – Editor & Project Settings API
• SlateCore – Fundamental UI functionality
• TargetPlatform – Platform abstraction layer
• UMG – Unreal Motion Graphics implementation
• UnrealEd – Unreal Editor main frame & features
![Page 14: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/14.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
Interesting Modules for Cool Features
• Analytics – Collects usage statistics from Editor & games
• AssetRegistry – Database for assets in Unreal Editor
• GameLiveStreaming – Twitch Streaming
• HeadMountedDisplay – HMD Support API (Oculus, etc.)
• JsonUtilities & XmlParser – Handle Json & XML files
• SourceControl – API for custom source control providers
![Page 15: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/15.jpg)
The Big Picture
Directories
Configuration
Modules
Projects
Your Game Projects can…
• Use Blueprints, C++ Code or both
• Contain any number of modules & plug-ins
• Be moved around and shared with others
Project Templates to Get You Started
• Blank (with or without sample content)
• First Person Shooter
• Side scroller, top-down & puzzle games
• Flying & driving games
• They all come in Blueprint and C++ flavors
• More to come, and make your own!
![Page 16: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/16.jpg)
Project Templates & Samples
![Page 17: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/17.jpg)
Project Packaging & Deployment
![Page 18: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/18.jpg)
Game Framework
![Page 19: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/19.jpg)
Game Framework History
UE1 and UE2
• Designed for First Person Shooters (FPS)
• UnrealScript game scripting language
UE3
• Kismet Visual Scripting added
• More modular game classes
• But still very FPS centric
UE4
• UnrealScript replaced with Blueprints
• Game genre agnostic
• Lots of sample projects!
![Page 20: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/20.jpg)
UnrealScript vs. C++ vs. Blueprints
UnrealScript was:
• An object-oriented scripting language
• Similar in syntax to C, C++, Java, but also somewhat different
• Compiled to virtual machine byte code
• Adding interesting features, such as States, Timers, Delegates
Blueprints are:
• A visual scripting system that is artist and designer friendly
• Using the same virtual machine as UnrealScript
• Almost as powerful as UnrealScript, and in many ways better
C++ has:
• Always been part of UE game programming
• Tight bi-directional integrations with the virtual machine
• Been greatly improved in UE4 to replace UnrealScript for codersC++
Blueprints
VM
![Page 21: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/21.jpg)
So What Is The Game Framework?
Overview
Why Use It?
Set Of Foundation Classes
• Provide basic structure and functions of your game
• You derive from the classes that you need
• Fill in the details for your particular game
What’s Missing?
• Game genre specific implementations
• No concept of health and death
• No built-in classes for weapons, inventory, etc.
![Page 22: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/22.jpg)
So What Is The Game Framework?
Overview
Why Use It?
Reduced Learning Curve
• Hides the low-level details of game engines
• Benefit from 20+ years of game developing experience
• Many samples and tutorials for solving common tasks
High Productivity
• Focus on what really matters to you: making your game
• Solves many tricky problems in games (movement, input, etc.)
• Greatly reduces boilerplate code needed for all games
Scalability
• Smoothly grow your game & team from prototype to AAA
![Page 23: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/23.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
What is an Actor?
• Entity in a game level
• Usually contains one or more Actor Components
• Supports network replication for multiplayer games
Things to know about Actors
• Don’t have Location, Rotation (stored in root component)
• Created with SpawnActor() method
• Must be destroyed explicitly with Destroy() method
• Will not be garbage collected during the game
![Page 24: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/24.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
What is an ActorComponent?
• Reusable functionality that can be added to an Actor
• Contain the most interesting functionality & events
Example Components:
• Scene Component – Adds transforms and attachments
• Primitive Component – Adds collision and rendering
• UAudioComponent, UArrowComponent,
UInputComponent, ULightComponent, UMeshComponent,
UParticleSystemComponent and many more!
![Page 25: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/25.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
PrimiviteComponent Event Examples
• Hit – Called when bumping into a wall
• Begin/EndOverlap – Walk into or out of a trigger
• Begin/EndCursorOver
• Clicked/Released
• InputTouchBegin/End
• Begin/EndTouchOver
Also accessible in Blueprints!
![Page 26: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/26.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
What is a Pawn?
• An agent in the world
• Optionally possessed by a Controller
• Usually handles movement and input
Things to know about Pawns
• Good place to implement health
• No movement or input code by default
![Page 27: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/27.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
What is a Character?
• Special Pawn that can walk
• Comes with useful Components
Things to know about Controllers
• Handles collision
• Client-side movement prediction
• Much improvement from UE3
![Page 28: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/28.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
What is a Controller?
• A brain that can possess a Pawn
• PlayerController: Represents a human player
• AIController: Computes AI behavior for Pawns
Things to know about Controllers
• Possess one Pawn at a time
• Can persist after possessed Pawn dies
![Page 29: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/29.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
PlayerController
• Interface for players to agents
• Handles touches, clicks, keyboard
• Showing/hiding mouse cursor
• Good place for non-agent code
• Menus, voice chat, etc.
• Many other useful options
![Page 30: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/30.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
What is a HUD?
• Head-Up Display
• Responsible for in-game UI
Things to know about Controllers
• Immediate-mode drawing API
• No tools for building HUDs
• UMG will provide all the things!
![Page 31: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/31.jpg)
Fundamental Concepts
Actors
Components
Pawn
Character
Controller
HUD
GameMode
What is a GameMode?
• Implements the game rules
• Configures default classes for Pawn, Controller, HUD, etc.
• Can be accessed from anywhere (GetGameMode())
Things to know about GameModes
• Only exists on the server and single player instances!
• GameState is used to replicate game state to clients
• Default game mode can be set in Project Settings
• Per-map overrides in World Settings
![Page 32: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/32.jpg)
Other Important Concepts
Input
Collision
Replication
Axes & Actions
• Can bind to mouse, keyboard, touch, etc.
• Defined in Project Settings
Input Processing Order
1. PlayerController
2. Level Blueprint
3. Possessed Pawn
![Page 33: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/33.jpg)
Other Important Concepts
Input
Collision
Replication
Various Collision Query Functions
• Line traces (ray casts)
• Geometry sweeps
• Overlap tests
Simple Collision
• Box, sphere, capsule, convex
• Authoring tools in Editor
• Used for movement, physics, etc.
Complex collision
• Actual graphics triangles
• Used for weapons, kinematics, etc.
![Page 34: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/34.jpg)
Other Important Concepts
Input
Collision
Replication
Transfer game state between Server and Clients
• Remote Procedure Calls (RPC)
• Data transfer (variables, structs, dynamic arrays)
• Editor supports multiplayer PIE testing
![Page 35: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/35.jpg)
Game Framework Flowchart
![Page 36: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/36.jpg)
Slate UI Framework
![Page 37: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/37.jpg)
UE1, UE2 and UE3
![Page 38: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/38.jpg)
![Page 39: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/39.jpg)
Slate Design & Principles
Overview
Features
Concepts
Tools
Architecture
• Written entirely in C++
• Platform agnostic (works on mobile and consoles, too!)
• SlateCore module provides low-level functionality
• Slate module contains library of common UI widgets
• Does not require Engine or Editor modules
Current Use Cases
• Unreal Editor
• Standalone desktop applications
• Mobile applications
• In-game UI
![Page 40: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/40.jpg)
Slate Design & Principles
Overview
Features
Concepts
Tools
Styling
• Customize the visual appearance of your UI
• Images (PNGs and Materials), Fonts, Paddings, etc.
• Customizable user-driven layouts
Input Handling
• Keyboard, mouse, joysticks, touch
• Key bindings support
Render Agnostic
• Supports both Engine renderer and standalone renderers
Large Widget Library
• Layout primitives, text boxes, buttons, images, menus, dialogs, message boxes, navigation, notifications, dock tabs, list views, sliders, spinners, etc.
![Page 41: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/41.jpg)
![Page 42: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/42.jpg)
Slate Design & Principles
Overview
Features
Concepts
Tools
Declarative Syntax
• Set of macros for declaring widget attributes
• Avoids layers of indirection
Composition
• Compose entire widget hierarchies in a few lines of code
• Uses fluent syntax for ease of use
• Preferred over widget inheritance
• Any child slot can contain any other widget type
• Makes it very easy to rearrange UIs in code
![Page 43: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/43.jpg)
// Example custom button (some details omitted)
class STextButton
: public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SMyButton )
{ }
// The label to display on the button.
SLATE_ATTRIBUTE(FText, Text)
// Called when the button is clicked.
SLATE_EVENT(FOnClicked, OnClicked)
SLATE_END_ARGS()
// Construct this button
void Construct( const FArguments& InArgs );
};
// Button implementation (some details omitted)
void STextButton::Construct ( const FArguments& InArgs )
{
ChildSlot
[
SNew(SButton)
.OnClicked(InArgs._OnClicked)
[
SNew(STextBlock)
.Font(FMyStyle::GetFontStyle(“TextButtonFont"))
.Text(InArgs._Text)
.ToolTipText(LOCTEXT(“TextButtonToolTip", “Click Me!"))
];
];
}
![Page 44: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/44.jpg)
Slate Design & Principles
Overview
Features
Concepts
Tools
Widget Inspector
• Visually debug and analyze your UI
• Can jump directly to widget code in Visual Studio or XCode
UDK Remote
• iOS app for simulating touch devices on your PC
• Remote server is a plug-in (enabled by default)
• Primarily used for game development
![Page 45: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/45.jpg)
![Page 46: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/46.jpg)
Demo
![Page 47: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/47.jpg)
Demo
![Page 48: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/48.jpg)
Going A Little Deeper
State Updates
Widget Roles
Anatomy
Attributes
Polling instead of Invalidation
• Avoids duplicate state data
• Exception: Non-trivial data models (use caches instead)
• Performance depends on number of visible widgets
![Page 49: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/49.jpg)
Going A Little Deeper
State Updates
Widget Roles
Anatomy
Attributes
Fundamental Widget Types
• SCompoundWidget – Can have nested child widgets
• SLeafWidget – Does not contain child widgets
• SPanel – Base class for layout panels
Special Widgets
• SWidget – Root base class for all widgets (do not inherit!)
• SNullWidget – Empty default widget
User Widgets
• More efficient in terms of compile time
![Page 50: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/50.jpg)
Going A Little Deeper
State Updates
Widget Roles
Anatomy
Attributes
Common Interfaces
• Arguments – Widget parameters that do not change
• Attributes – Parameters that are polled
• Event handlers – Usually named ‘OnSomeEvent’
Common Internals
• ComputeDesiredSize() - Calculates widget’s desired size
• ArrangeChildren() - Arranges children within allotted area
• OnPaint() – Draws the widget
![Page 51: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/51.jpg)
Going A Little Deeper
State Updates
Widget Roles
Anatomy
Attributes
Common Attributes
• Enabled state, Visibility, Hit testability
• Tooltip Widget, Tooltip Text, Cursor Style
• Horizontal & Vertical Alignment , Padding
Attributes Can Be:
• Constants, i.e. IsEnabled(false)
• Delegate bindings,
i.e. IsEnabled(this, &SMyWidget::HandleIsEnabled)
![Page 52: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/52.jpg)
Current In-Game UI Features
HUD Canvas
VP Widgets
Game Menus
FCanvas
• Low-level C++ API for drawing directly to the screen
• Has been part of Unreal Engine for many years
• All functions are in FCanvas class
• DrawText(), DrawTexture(), DrawTile(), etc.
• Use AHUD.Canvas to access the canvas object
HHitProxy
• Provides basic interaction support for FCanvas
• Create one hit proxy per interactive object
• Hit proxy ID is sent to GPU for per-pixel hit tests
![Page 53: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/53.jpg)
Current In-Game UI Features
HUD Canvas
VP Widgets
Game Menus
UGameViewportClient
• Allows usage of Slate widgets inside game view port
• Use all features of Slate (except SWindow)
• Add/RemoveViewportWidgetContent()
Things to keep in mind
• All added widgets will be layered on top of each other (SOverlay)
• Widgets should use TWeakObjPtr for UObject references
![Page 54: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/54.jpg)
![Page 55: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/55.jpg)
![Page 56: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/56.jpg)
Current In-Game UI Features
HUD Canvas
VP Widgets
Game Menus
The Hard Way
• Use FCanvas to draw your own menus
• Not recommended
The Custom Way
• Use HUD Widgets to create any menu layout
The Lazy Way
• Use GameMenuBuilder for paged menus
• FGameMenuPage - Single menu page
• FGameMenuItem - An option in a menu page
• Can be customized and styled
• Mostly used for settings screens
![Page 57: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/57.jpg)
Unreal Motion Graphics (UMG)
![Page 58: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/58.jpg)
Unreal Motion Graphics
Overview
Scripting
Upcoming
One UI Solution To Rule Them All
• Built on top of Slate
• Adds real-time animation and transformation to widgets
• Integrated with Blueprints
• WYSIWYG Editor for artists and designers
• No programming required (unless you want to)
• Not officially released yet, but already in the code base
![Page 59: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/59.jpg)
![Page 60: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/60.jpg)
![Page 61: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/61.jpg)
![Page 62: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/62.jpg)
![Page 63: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/63.jpg)
![Page 64: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/64.jpg)
![Page 65: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/65.jpg)
![Page 66: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/66.jpg)
![Page 67: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/67.jpg)
![Page 68: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/68.jpg)
Unreal Motion Graphics
Overview
Scripting
Upcoming
Adding Behavior to your UI
• Designers should not have to write code!
• Blueprints allow scripting of UI
• You can still use C++ as well, but probably won’t
![Page 69: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/69.jpg)
![Page 70: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/70.jpg)
Unreal Motion Graphics
Overview
Scripting
Upcoming
Currently working on:
• Materials!
• Style assets
• 2D Transforms
• Special effects
• In-world 3D UI
• Workflow polish
![Page 71: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/71.jpg)
![Page 72: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/72.jpg)
Arbitrary 2D Transforms
![Page 73: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/73.jpg)
• Attachable UI Actor Components
• Injected into render stream
• Can intersect with world geometry
• Render to texture (optional)
• 3D Transformations
In-World 3D User Interfaces
![Page 74: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/74.jpg)
Extensibility
![Page 75: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/75.jpg)
Why Do We Want Extensibility?
Custom Requirements
• Features that are too specific to be included in UE4
• Features that UE4 does not provide out of the box
Third Party Technologies
• Features owned and maintained by other providers
• Scaleform, SpeedTree, CoherentUI, etc.
Flexibility & Maintainability
• More modular code base
• Easier prototyping of new features
![Page 76: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/76.jpg)
How To Extend The Engine
General
Games
Editor
Plug-ins
UE3: Engine Code Changes
• Only accessible to licensees
• Required deep understanding of code base
• Merging Engine updates was tedious
UE4: Extensibility APIs
• Modules, plug-ins, C++ interfaces
• Native code accessible to everyone
• Also supports non-programmers
![Page 77: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/77.jpg)
How To Extend The Engine
General
Games
Editor
Plug-ins
Blueprint Construction Scripts
• Blueprints as macros to create & configure game objects
• Activated when an object is created in Editor or game
• Check out our excellent tutorials on YouTube!
![Page 78: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/78.jpg)
![Page 79: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/79.jpg)
How To Extend The Engine
General
Games
Editor
Plug-ins
Details View Customization
• Change the appearance of your types in the Details panel
• Customize per class, or per property
• Inject, modify, replace, or remove property entries
Menu Extenders
• Inject your own options into the Editor’s main menus
Tab Manager
• Register your own UI tabs
• Allows for adding entirely new tools and features
![Page 80: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/80.jpg)
Default Appearance Detail Customizations
![Page 81: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/81.jpg)
How To Extend The Engine
General
Games
Editor
Plug-ins
Blutilities
• Blueprints for the Editor!
• No C++ programming required
• Can fire off events that effect the Editor
• Currently experimental, but already working
• Scheduled for 4.5 (may change)
![Page 82: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/82.jpg)
Procedural Textures, L-Systems, Flipbooks
![Page 83: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/83.jpg)
How To Extend The Engine
General
Games
Editor
Plug-ins
Overview
• Extend the Engine, the Editor, or both
• Are completely self contained
• Can be enabled and disabled per project
• Everything should be a plug-in!
Examples
• BlankPlugin, UObjectPlugin – Use these to start coding
• Perforce & Subversion support for the Editor
• Oculus Rift support
• Movie players, Twitch Live Streaming, Slate Remote
• And many more!
![Page 84: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/84.jpg)
![Page 85: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/85.jpg)
How To Extend The Engine
General
Games
Editor
Plug-ins
All Plug-ins
• Will be loaded automatically on startup (if enabled)
• Most not be dependencies of the Engine or other plug-ins
Plug-ins with Code
• Have their own ‘Source’, ‘Binaries’, ‘Intermediates’ folders
• Can have one or more code modules
• May declare new UObject and UStruct types
• Seldom have Public header files in modules
Plug-ins with Content
• Have their own ‘Content’ folder
• Configuration files (INIs) not supported yet
![Page 86: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/86.jpg)
How To Extend The Engine
General
Games
Editor
Plug-ins
Descriptor Files (.uplugin)
{
"FileVersion" : 3,
"FriendlyName" : "Paper2D",
"Version" : 1,
"VersionName" : "1.0",
"CreatedBy" : "Epic Games, Inc.",
"CreatedByURL" : "http://epicgames.com",
"EngineVersion" : "4.2.0",
"Description" : "Paper2D.",
"Category" : "2D.Helpers",
"EnabledByDefault" : true,
"Modules" :
[
// module definitions omitted
],
"CanContainContent" : true
}
![Page 87: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/87.jpg)
![Page 88: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/88.jpg)
Vertex Snapping, Ocean Surface, Rollercoaster
More on the Wiki!
![Page 89: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/89.jpg)
Questions?
Documentation, Tutorials and Help at:
• AnswerHub:
• Engine Documentation:
• Official Forums:
• Community Wiki:
• YouTube Videos:
• Community IRC:
Unreal Engine 4 Roadmap• lmgtfy.com/?q=Unreal+engine+Trello+
http://answers.unrealengine.com
http://docs.unrealengine.com
http://forums.unrealengine.com
http://wiki.unrealengine.com
http://www.youtube.com/user/UnrealDevelopmentKit
#unrealengine on FreeNode
![Page 90: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/90.jpg)
Concurrency & Parallelism
![Page 91: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/91.jpg)
Synchronization Primitives
Atomics
Locking
Signaling
Waiting
FPlatformAtomics
• InterlockedAdd
• InterlockedCompareExchange (-Pointer)
• InterlockedDecrement (-Increment)
• InterlockedExchange (-Pointer)
64- and 128-bit overloads on supported platforms
![Page 92: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/92.jpg)
Synchronization Primitives
Atomics
Locking
Signaling
Waiting
// Example
class FThreadSafeCounter
{
public:
int32 Add( int32 Amount )
{
return FPlatformAtomics::InterlockedAdd(&Counter, Amount);
}
private:
volatile int32 Counter;
};
![Page 93: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/93.jpg)
Synchronization Primitives
Atomics
Locking
Signaling
Waiting
Critical Sections
• FCriticalSection implements synchronization object
• FScopeLock for scope level locking using a critical section
• Fast if the lock is not activated
Spin Locks
• FSpinLock can be locked and unlocked
• Sleeps or spins in a loop until unlocked
• Default sleep time is 0.1 seconds
![Page 94: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/94.jpg)
Synchronization Primitives
Atomics
Locking
Signaling
Waiting
Semaphores
• Like mutex with signaling mechanism
• Only implemented for Windows and hardly used
• API will probably change
• Use FEvent instead
![Page 95: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/95.jpg)
Synchronization Primitives
Atomics
Locking
Signaling
Waiting
FEvent
• Blocks a thread until triggered or timed out
• Frequently used to wake up worker threads
FScopedEvent
• Wraps an FEvent that blocks on scope exit
// Example for scoped events
{
FScopedEvent Event;
DoWorkOnAnotherThread(Event.Get());
// stalls here until other thread triggers Event
}
![Page 96: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/96.jpg)
High Level Constructs
Containers
Helpers
General Thread-safety
• Most containers (TArray, TMap, etc.) are not thread-safe
• Use synchronization primitives in your own code where needed
TLockFreePointerList
• Lock free, stack based and ABA resistant
• Used by Task Graph system
TQueue
• Uses a linked list under the hood
• Lock and contention free for SPSC
• Lock free for MPSC
TDisruptor (currently not part of UE4)
• Lock free MPMC queue using a ring buffer
![Page 97: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/97.jpg)
High Level Constructs
Containers
Helpers
FThreadSafeCounter
FThreadSingleton
• Singleton that creates an instance per thread
FMemStack
• Fast, temporary per-thread memory allocation
TLockFreeClassAllocator, TLockFreeFixedSizeAllocator
• Another fast allocator for instances of T
FThreadIdleStats
• Measures how often a thread is idle
![Page 98: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/98.jpg)
Parallelization
Threads
Task Graph
Processes
Messaging
FRunnable
• Platform agnostic interface
• Implement Init(), Run(), Stop() and Exit() in your sub-class
• Launch with FRunnableThread::Create()
• FSingleThreadRunnable when multi-threading is disabled
FQueuedThreadPool
• Carried over from UE3 and still works the same way
• Global general purpose thread pool in GThreadPool
• Not lock free
![Page 99: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/99.jpg)
Parallelization
Threads
Task Graph
Processes
Messaging
Game Thread
• All game code, Blueprints and UI
• UObjects are not thread-safe!
Render Thread
• Proxy objects for Materials, Primitives, etc.
Stats Thread
• Engine performance counters
![Page 100: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/100.jpg)
Parallelization
Threads
Task Graph
Processes
Messaging
Task Based Multi-Threading
• Small units of work are pushed to available worker threads
• Tasks can have dependencies to each other
• Task Graph will figure out order of execution
Used by an increasing number of systems
• Animation evaluation
• Message dispatch and serialization in Messaging system
• Object reachability analysis in garbage collector
• Render commands in Rendering sub-system
• Various tasks in Physics sub-system
• Defer execution to a particular thread
![Page 101: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/101.jpg)
![Page 102: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/102.jpg)
Parallelization
Threads
Task Graph
Processes
Messaging
FPlatformProcess
• CreateProc() executes an external program
• LaunchURL() launches the default program for a URL
• IsProcRunning() checks whether a process is still running
• Plus many other utilities for process management
FMonitoredProcess
• Convenience class for launching and monitoring processes
• Event delegates for cancellation, completion and output
![Page 103: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/103.jpg)
Parallelization
Threads
Task Graph
Processes
Messaging
Unreal Message Bus (UMB)
• Zero configuration intra- and inter-process communication
• Request-Reply and Publish-Subscribe patterns supported
• Messages are simple UStructs
Transport Plug-ins
• Seamlessly connect processes across machines
• Only implemented for UDP right now (prototype)
![Page 104: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/104.jpg)
![Page 105: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/105.jpg)
Upcoming Features
Critical sections & events
• Better debugging and profiling support
Task Graph
• Improvements and optimizations
UObjects
• Thread-safe construction and destruction
Parallel Rendering
• Implemented inside renderers, not on RHI API level
Messaging
• UDP v2 (“Hammer”), BLOB attachments, more robust, breakpoints
• Named Pipes and other transport plug-ins
More lock-free containers
![Page 106: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/106.jpg)
Appendix A: Programming Tips
![Page 107: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/107.jpg)
Getting Started
Tools:
• Windows: Visual Studio, UnrealVS, Visual Assist X (recommended)
• MacOS: XCode
For everything else see:
https://docs.unrealengine.com/latest/INT/Programming/QuickStart/
![Page 108: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/108.jpg)
Common Blockers
Compiling
Acronyms
Entry Point
Compiling is handled through UBT
• UBT – Unreal Build Tool
• Solution/Projects in Visual Studio and Xcode are a lie!
![Page 109: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/109.jpg)
Common Blockers
Compiling
Acronyms
Entry Point
Acronym Soup (and Code Names, too)
• UBT – Unreal Build Tool
• UHT – Unreal Header Tool
• UAT – Unreal Automation Tool
• UFE – Unreal Frontend
• BP – Blueprint
• CDO – Class Default Object
• INI – Text Based Configuration File
• Cooking – Optimizing game content
• Lightmass, Persona, Cascade, Swarm and other tools
• etc. pp.
![Page 110: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/110.jpg)
Common Blockers
Compiling
Acronyms
Entry Point
I Want To Understand the Engine - Where Is the Main Loop?
• LaunchEngineLoop.cpp
• It’s really complicated (and everybody hates it)
• Please don’t bother with this – start with our tutorials!
![Page 111: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/111.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
We Use Prefixes for All Types
• U – UObject derrived class, i.e. UTexture
• A – AActor derrived class, i.e. AGameMode
• F – All other classes and structs, i.e. FName, FVector
• T – Template, i.e. TArray, TMap, TQueue
• I – Interface class, i.e. ITransaction
• E – Enumeration type, i.e. ESelectionMode
• b – Boolean value, i.e. bEnabled
Everything in Unreal is Pascal Case (Upper Camel Case)
• Function names and function parameters, too
• Even local and loop variables!
![Page 112: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/112.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
UObjects Work Around Limitations in C++
• Run-time reflection of class properties and functions
• Serialization from/to disk and over the network
• Garbage collection
• Meta data
• Also: Blueprint integration
Decorate regular C++ Classes with Magic Macros
• UCLASS – for class types
• USTRUCT – for struct types
• UFUNCTION – for class and struct member functions
• UPROPERTY – for class and struct variables
![Page 113: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/113.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
// Example (not actual UE4 code – omitting some more advanced details)
USTRUCT()
struct FVector2D
{
UPROPERTY()
float X;
UPROPERTY()
float Y;
UFUNCTION ()
float GetLength() const;
};
![Page 114: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/114.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
Fundamental Types
• We don’t use C++ integer types (char, short, int, long, etc.)
• Custom typedef’s for ints & strings in GenericPlatform.h
(int32, uint32, uint64, TCHAR, ANSICHAR etc.)
• Numeric type traits in NumericLimits.h
Common Structures
• FBox, FColor, FGuid, FVariant, FVector, TBigInt, TRange
• And many more in Core module
![Page 115: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/115.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
Containers
• TArray, TSparseArray – Dynamic arrays
• TLinkedList, TDoubleLinkedList
• TMap – Key-value hash table
• TQueue – Lock free FIFO
• TSet – Unordered set (without duplicates)
• And many more in Core module
Delegates
• Unicast and multicast delegates
• Also thread-safe variants
![Page 116: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/116.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
Smart Pointers
• TSharedPtr, TSharedRef – for regular C++ objects
• TWeakPtr – for regular C++ objects
• TWeakObjPtr – for UObjects
• TAutoPtr, TScopedPtr
• TUniquePtr
• Similar to boost:: & std:: implementations
• Also thread-safe variants
![Page 117: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/117.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
String Types
• FString – Regular string
• FText – Localized string, used heavily in Slate UI
• FName – String hash, used heavily in UObjects
String Literals
• TEXT() – Creates a regular(!) string, i.e. TEXT(“Hello”);
• LOCTEXT() – Creates a localized string, i.e.LOCTEXT(“Namespace”, “Name”, “Hello”);
• NSLOCTEXT() – LOCTEXT with scoped namespace, i.e.NSLOCTEXT(“Name”, “Hello”);
![Page 118: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/118.jpg)
![Page 119: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/119.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
FNames are case-insensitive!
• Can’t rename ‘MisSpelled’ to ‘Misspelled’ in the Editor
• Can’t name a property ‘Blast’ if one ‘bLast’ exists
![Page 120: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/120.jpg)
Unrealisms
Type Names
UObjects
Basic Types
Strings
Macros
Logging
• UE_LOG, also GLog->Logf()
Assertions
• check(), checkSlow(), ensure()
Localization
• LOCTEXT_NAMESPACE, LOCTEXT, etc.
Slate (UI Framework)
• SLATE_BEGIN_ARGS, SLATE_ATTRIBUTE, etc.
![Page 121: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/121.jpg)
Best Practices
Guidelines
Principles
Coding Guidelines
• Posted on http://docs.unrealengine.com
• There are some inconsistencies in the code base
• If in doubt, follow existing style in current code file
Naming Conventions
• Choose descriptive names that are as short as possible
• Also for local and loop variables!
• Avoid your own acronyms
![Page 122: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/122.jpg)
Best Practices
Guidelines
Principles
General Principles
• KISS, YAGNI
• Composition vs. inheritance
• Avoid tight coupling of code and modules
• Many trivial instead of few complicated components
Design Patterns
• SOLID (especially S, O, L and I; DI is not elegant in C++)
• Hollywood Principle (especially for Slate & game code)
• GOF, EIP
Methodologies
• DDD, TDD (we support unit tests), AOP
![Page 123: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/123.jpg)
Appendix B: Build Automation
![Page 124: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/124.jpg)
Build Tools
UHT
UBT
UAT
Unreal Header Tool (UHT)
• Written in C++
• Parses all C++ headers containing UClasses
• Generates glue code for all Unreal classes & functions
• Generated files stored in Intermediates directory
![Page 125: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/125.jpg)
Build Tools
UHT
UBT
UAT
Unreal Build Tool (UBT)
• Written in C# (may convert to C++ in the future)
• Scans solution directory for modules and plug-ins
• Determines all modules that need to be rebuilt
• Invokes UHT to parse C++ headers
• Creates compiler & linker options from .Build.cs & .Target.cs
• Executes platform specific compilers (VisualStudio, LLVM)
Other UBT Features
• Project file generation (GenerateProjectFiles.bat)
• Remote Compilation (iOS, MacOS)
![Page 126: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/126.jpg)
Build Rules
![Page 127: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/127.jpg)
Dependency Graph
![Page 128: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/128.jpg)
Build Tools
UHT
UBT
UAT
Unreal Automation Tool (UAT)
• Written in C# (may convert to C++ in the future)
• Automates repetitive tasks through Automation Scripts
• Build, cook, package, deploy and launch projects
• Invokes UBT for compilation
Other UAT Scripts
• Analyze and fix up game content files
• Code surgery when updating to new Engine versions
• Distributed compilation (XGE) & build system integration
• Generate code documentation
• Automated Testing of code and content
• And many others – you can add your own scripts!
![Page 129: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/129.jpg)
UBT, UHT, UAT Projects
![Page 130: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/130.jpg)
Build Automation
SCC
CIS
Promotion
Testing
Source Code Control (SCC)
• We use Perforce, but you don’t have to
• Not just code, but also content and everything else
• Also contains compiled binaries from build system (!)
• Used to version many other things (Markting, QA, etc.)
GitHub Integration
• Check-ins are pushed to GitHub Master in near real-time
• Script for converting GitHub pull requests to P4 CLs
![Page 131: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/131.jpg)
Build Automation
SCC
CIS
Promotion
Testing
Continuous Integration System (CIS)
• Verifies all check-ins of code and content
• Grand Unified Build Process (GUBP)
• Thousands of build tasks a day
Backend Software
• Used custom build server for several years
• Experimented with Jenkins, but not scalable enough
• Now using Electric Commander
• Complex workflows with hundreds of jobs and sub-tasks
Build Hardware
• Virtualized farm of Windows and MacOS build servers
![Page 132: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/132.jpg)
GUBP
![Page 133: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/133.jpg)
Build Automation
SCC
CIS
Promotion
Testing
Build Promotion
• Selected successful CIS builds are tested by QA
• Builds that pass QA will be promoted to stable
• Selected stable builds become release candidates
• Approved stable builds are released to public
![Page 134: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/134.jpg)
Build Automation
SCC
CIS
Promotion
Testing
UnrealSync
• Tool for artists to fetch the latest promoted build
• Aware of P4 branches and projects
• Notifies user when new promoted build is available
![Page 135: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/135.jpg)
Build Automation
SCC
CIS
Promotion
Testing
Automated Testing
• Simple and complex tests
• Unit tests for C++, content verification
• Parallel testing on multiple platforms & devices
• Can also run from command line (as a Commandlet)
Simple Tests
• Single atomic test that can pass or fail
• Unit tests for C++, feature tests for content
• Examples: Play a map in PIE, verify text wrapping in Slate, etc.
Complex Tests
• Run same test code on a number of inputs
• Examples: Load all maps in the Editor, compile all Blueprints, etc.
![Page 136: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/136.jpg)
// Example for a simple automation test that runs in a game
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSetResTest, "Windows.SetResolution", ATF_Game)
bool FSetResTest::RunTest( const FString& Parameters )
{
FString MapName = TEXT("AutomationTest");
FEngineAutomationTestUtilities::LoadMap(MapName);
int32 ResX = GSystemSettings.ResX;
int32 ResY = GSystemSettings.ResY;
FString RestoreResolutionString = FString::Printf(TEXT("setres %dx%d"), ResX, ResY);
ADD_LATENT_AUTOMATION_COMMAND(FEngineWaitLatentCommand(2.0f));
ADD_LATENT_AUTOMATION_COMMAND(FExecStringLatentCommand(TEXT("setres 640x480")));
ADD_LATENT_AUTOMATION_COMMAND(FEngineWaitLatentCommand(2.0f));
ADD_LATENT_AUTOMATION_COMMAND(FExecStringLatentCommand(RestoreResolutionString));
return true;
}
Simple Automation Test
![Page 137: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/137.jpg)
Automation Test Demo
![Page 138: GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things to Come](https://reader034.vdocuments.mx/reader034/viewer/2022042509/55a6d73a1a28ab72298b45f3/html5/thumbnails/138.jpg)
Questions?
Documentation, Tutorials and Help at:
• AnswerHub:
• Engine Documentation:
• Official Forums:
• Community Wiki:
• YouTube Videos:
• Community IRC:
Unreal Engine 4 Roadmap• lmgtfy.com/?q=Unreal+engine+Trello+
http://answers.unrealengine.com
http://docs.unrealengine.com
http://forums.unrealengine.com
http://wiki.unrealengine.com
http://www.youtube.com/user/UnrealDevelopmentKit
#unrealengine on FreeNode