If you want to help us maintaining this wiki, check out our discord server: https://discord.gg/3u69jMa
Difference between revisions of "Writing Native Code"
Jump to navigation
Jump to search
(→Code) |
|||
Line 1: | Line 1: | ||
== | ==Introduction== | ||
Native coding in the Unreal Engine refers to code that is written in C++ instead of UnrealScript. This C++ code can be called from a script to execute tasks that are either too slow in UnrealScript (about 20 times slower than C++) or are not possible at all due to the limited features of the language. | |||
Native coding | |||
==Introduction== | ==Introduction== |
Revision as of 16:45, 27 January 2018
Introduction
Native coding in the Unreal Engine refers to code that is written in C++ instead of UnrealScript. This C++ code can be called from a script to execute tasks that are either too slow in UnrealScript (about 20 times slower than C++) or are not possible at all due to the limited features of the language.
Introduction
Getting Started
Code
This code assumes that the folders with the headers for Core and Engine are in the same directory as the source file
//Linking the import libraries for Core.dll and Engine.dll so that functions from these libraries can be called
#pragma comment(lib, "Core/lib/Core.lib")
#pragma comment(lib, "Engine/lib/Engine.lib")
//Including the headers for core and engine
#include "Engine/Inc/Engine.h"
//This function is going to replace appInit from UnFile.h and thus needs to have the same signature
__declspec(dllexport) void testFunc(const char* InPackage, const char* InCmdLine, FOutputDevice* InLog, FOutputDeviceError* InError,
FFeedbackContext* InWarn, FConfigCache*(*ConfigFactory)(), int RequireConfig){
const char* newCmdLine = "-windowed -log abcdefg 12345";
InLog->Logf("Replacing command line with %s", newCmdLine);
appInit(InPackage, newCmdLine, InLog, InError, InWarn, ConfigFactory, RequireConfig);
}