SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 30 day free trial to unlock unlimited reading.
FMX 2017: Extending Unreal Engine 4 with Plug-ins (Master Class)
Overview on creating code projects and plug-ins, and introduction on how to add new asset types to UE4 and customize their look & feel via asset actions and custom asset editors. The corresponding source code is available at https://headcrash.industries/vault/presentations/fmx/
Overview on creating code projects and plug-ins, and introduction on how to add new asset types to UE4 and customize their look & feel via asset actions and custom asset editors. The corresponding source code is available at https://headcrash.industries/vault/presentations/fmx/
FMX 2017: Extending Unreal Engine 4 with Plug-ins (Master Class)
1.
FMX 2017 Master Class
Extending Unreal Engine 4 with Plug-ins
Gerke Max Preussner | Sr. Engine Programmer | Epic Games
@gmpreussner | max.preussner@epicgames.com | linkedin.com/in/gmpreussner
2.
What You’re Going To Learn Today
UE4 Programming Basics
• Structure of UE4 code base
Files, Directories, Engine, Projects
• Creating a UE4 plug-in
Anatomy, Descriptor Files
Extending the Engine & Editor
• Adding new content asset types
We’ll create an asset that stores text
• Implementing asset factories
New assets via context menu and drag & drop
• Editor integration of assets
Appearance, actions, custom UI
3.
Prerequisites
Required
• Unreal Engine 4
www.unrealengine.com/download
• Visual Studio 2015 or 2017
Community or Professional Editions
Recommended
• Refactoring Tools
we use Visual Assist X (VAX)
• Distributed Build System
we use Xoreax IncrediBuild
• UnrealVS Extension
EngineExtrasUnrealVS
20.
Plugin Structure
Plugin Descriptor
• Version information
• Description
• Web links
• Options
• Module loading rules
21.
Engine Structure
Module Types
• Development
For any application, but used during development only
• Editor
For use in Unreal Editor only
• Runtime
For any application at any time
• ThirdParty
Code and libraries from external third parties
• Note: The UE4 EULA prohibits inclusion of Editor
modules in shipping games and applications
22.
An Actual Plug-in: TextAsset
https://github.com/ue4plugins/TextAsset
25.
An Actual Plug-in: TextAsset
Plug-in Demonstration
26.
Asset Types Overview
Common Tasks
• Declare the asset type’s C++ class
This is the actual asset
• Implement asset factories
This is how users create instances of the asset
• Customize asset appearance in Editor
Thumbnails, colors, detail customizations, filtering, categorization, etc.
• Asset-specific Content Browser actions
Things you can do when right-clicking an asset
• Advanced: Custom asset editor UI
For complex asset types
30.
Asset Factories
UFactory
• Base class for all asset factories
• Core logic for Editor integration
• Virtual functions to be overridden
• Very old API :(
Factory Types
• Content Browser Context Menu
Right-click menu in the Editor
Name: {TypeName}FactoryNew
• Content Browser Drag & Drop
Files on disk dragged into the Editor
Name: {TypeName}Factory
• Automatic Reimport
Recreate assets when files on disk changed
Name: Reimport{TypeName}Factory
40.
Asset Actions
FMX2017/Plugins/TextAsset/Source/TextAssetEditor/Private/AssetTools/TextAssetActions.cpp
Note: Asset categories are currently implemented as enumerations, so that their
total number is limited to 31 :(
44.
Anatomy of Modules
Files
• {ModuleName}.Build.cs
Build rules & configuration
• {ModuleName}.cpp
Module implementation
Directories
• {ModuleName}
This is where the module files live
• {ModuleName}/Public
Header files that are visible to other modules (optional)
• {ModuleName}/Private
Internal implementation of the module
45.
Anatomy of Modules
Files
• {ModuleName}.Build.cs
Build rules & configuration
• {ModuleName}.cpp
Module implementation
Directories
• {ModuleName}
This is where the module files live
• {ModuleName}/Public
Header files that are visible to other modules (optional)
• {ModuleName}/Private
Internal implementation of the module
46.
Anatomy of Modules
Example: /Source/Test/Test.Build.cs /Source/Test/Private/TestModule.cpp
47.
Anatomy of Modules
Example: /Source/Test/Test.Build.cs /Source/Test/Private/TestModule.cpp
49.
Asset Thumbnails
• Thumbnails can be any UI widget, incl. 3D viewports
• TextAsset doesn’t implement thumbnails
• Search the Engine code base for UThumbnailRenderer (if you’re curious)
52.
Slate
Slate UI Library
• 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
53.
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
Slate
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.
54.
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
Slate
55.
// 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!"))
];
];
}
Slate
60.
What You Learned Today
UE4 Programming Basics
• Structure of UE4 code base
Files, Directories, Engine, Projects
• Creating a UE4 plug-in
Anatomy, Descriptor Files
Extending the Engine & Editor
• Adding new content asset types
We’ll create an asset that stores text
• Implementing asset factories
New assets via context menu and drag & drop
• Editor integration of assets
Appearance, actions, custom UI
61.
Questions?
Documentation, Tutorials and Help
• Answer Hub
• Documentation
• Forums
• Issue Tracker
• Wiki
Other Resources
• UE4 Road Map
• YouTube Tutorials
• Community Discord
• Community IRC
answers.unrealengine.com
docs.unrealengine.com
forums.unrealengine.com
issues.unrealengine.com
wiki.unrealengine.com
trello.com/b/TTAVI7Ny/ue4-roadmap
www.youtube.com/user/UnrealDevelopmentKit
unrealslackers.org
#unrealengine on FreeNode
62.
You can download this presentation from SlideShare:
http://www.slideshare.net/GerkeMaxPreussner
You can clone or fork the TextAsset plug-in from GitHub:
https://github.com/ue4plugins/TextAsset
Gerke Max Preussner | Sr. Engine Programmer | Epic Games
@gmpreussner | max.preussner@epicgames.com | linkedin.com/in/gmpreussner