Skip to content

Latest commit

 

History

History
214 lines (164 loc) · 4.88 KB

UE4.md

File metadata and controls

214 lines (164 loc) · 4.88 KB

Environment Variables

  • UE4_GITDEPS: local path for shared UE4 git dependencies storage

Building

  • Disable optimization for the entire module:
OptimizeCode = CodeOptimization.Never;
  • Disable unity build for the entire module:
bFasterWithoutUnity = true;
  • Enable logging in the shipping build:
bUseLoggingInShipping = true;
  • Conditional compilation based on engine version:
In C++:
Use ENGINE_MAJOR_VERSION, ENGINE_MINOR_VERSION, ENGINE_PATCH_VERSION defined in Version.h

In C#:
Use UE_4_X_OR_LATER macro, such as UE_4_17_OR_LATER
  • Use private engine headers:
string EnginePath = Path.GetFullPath(Target.RelativeEnginePath);
PrivateIncludePaths.Add(Path.Combine(EnginePath, "Source/Runtime/OpenGLDrv/Private"));

Running

  • To execute console command during startup, use:
<YOUR GAME>.exe -ExecCmds="<COMMAND 1>,<COMMAND 2>,<COMMAND 3>"

You can also use this method to override CVars via the command line:

<YOUR GAME>.exe -ExecCmds="<CVAR 1> <VALUE 1>,<CVAR 2> <VALUE 2>"

Packaging

  • Additional cmd line param can be added to the packaged build via the RunUAT script:
-addcmdline="<PARAM>"
  • Add "-Messaging" cmd line param to the packaged build to make it communicate with the Session Frontend feature in the editor

Android

  • To send a console command via adb:
adb shell "am broadcast -a android.intent.action.RUN -e cmd '<COMMAND>'"

or 

doskey com=adb shell "am broadcast -a android.intent.action.RUN -e cmd '$*'"
com <COMMAND>
  • To pull logs from the device
adb pull /sdcard/UE4Game/<ProjectName>/<ProjectName>/Saved/Logs
  • Screenshot
adb shell screencap -p /sdcard/screencap.png
adb pull /sdcard/screencap.png
  • Launch an application
adb shell am start -n com.yourcompany.yourproject/com.epicgames.ue4.GameActivity
  • Realtime logging
adb logcat

Cooking

  • Add the following to the cmd line to manually start a cooking process
-run=Cook -TargetPlatform=<IOS|TVOS|Android_ASTC|...>
  • To enable cooking size reporting:
dg.EnableObjectCookingStats=1
dg.MinObjectSizeForCookingStats=X

Debugging

  • To launch a macOS cooked build from Xcode, set the executable to
PackagedGame/<PLATFORM>/<GAME>.app/Contents/MacOS/<GAME>

And set the working directory to

PackagedGame/<PLATFORM>/<GAME>.app/Contents/MacOS
  • To block the UE4 process until the debugger is attached, set -WaitForDebugger in the cmd line

  • To enable debug view modes in cooked build, set the following:

ConsoleVariables.ini:
r.ForceDebugViewModes=1

Console Variables

  • Several ways to define a console variable (cvar) in UE4:
static int32 GFoo = 1;
static FAutoConsoleVariableRef CVarFoo(
	TEXT("<NAME>"),
	GFoo,
	TEXT("<DESCRIPTION>")
	);


static TAutoConsoleVariable<int32> CVarFoo(
	TEXT("<NAME>"),
	<DEFAULT VALUE>,
	TEXT("<DESCRIPTION>"),
	ECVF_ReadOnly);
	
	
static void CommandImplementation(UWorld* InWorld)
{
  ...
}

FAutoConsoleCommandWithWorld Command(
	<NAME>,
	<DESCRIPTION>,
	FConsoleCommandWithWorldDelegate::CreateStatic(&CommandImplementation)
);	

PSO Caching

  1. Enable the following in the project settings
DefaultEngine.ini:
[SystemSettings]
r.ShaderPipelineCache.Enabled=1
r.ShaderPipelineCache.SaveUserCache=1

[DevOptions.Shaders]
; Required for enabling PSO
NeedsShaderStableKeys=true

DefaultGame.ini:
[/Script/UnrealEd.ProjectPackagingSettings]
bShareMaterialShaderCode=True
bSharedMaterialNativeLibraries=True
  1. Cook the project, make sure Saved/Cooked/<PLATFORM>/<PROJECT>/Metadata/PipelineCaches is generated

  2. Run a "gather PSO" session in the game, on the device, try to load as many assets as possible. Make sure these settings are enabled for the gathering session:

r.ShaderPipelineCache.LogPSO=1
r.ShaderPipelineCache.PrintNewPSODescriptors=1
r.ShaderPipelineCache.SaveBoundPSOLog=1
  1. Copy the gathered data (/Saved/CollectedPSOs/*.rec.upipelinecache) from the device to the dev machine, along side the PSO data generated by the cooker. Here's a suggestion of the folder structure:
Intermediate
  PSO
    <PLATFORM>
      CollectedPSOs
      	*.rec.upipelinecache
      PipelineCaches
      	ShaderStableInfo-<PROJECT>-<SHADER_PLATFORM>.scl.csv
	ShaderStableInfo-Global-<SHADER_PLATFORM>.scl.csv
  1. Run a UE4 commandlet to combine the data into the PSO cache:
-run=ShaderPipelineCacheTools expand <PSOCaching-DIR>/*.rec.upipelinecache <PSOCaching-DIR>/*.scl.csv <GENERATED-FILE>
  1. Copy the generated file to Build/<PLATFORM>/PipelineCaches, then recook.

  2. Repeat step #2 - #6 when the assets change in the project

Network Debugging and Testing

  • Use stat net to display networking related stats in the engine

  • To simulate bad network condition (see FPacketSimulationSettings::ParseSettings):

net PktEmulationProfile=<Off|Average|Bad>; see BaseEngine.ini
net PktLoss=<NUMBER>
net PktLag=<NUMBER>
net PktLagVariance=<NUMBER>