I love the smell of UnrealEd crashing in the morning. – tarquin
User:00zX/Using The Unreal Engine 3 Preprocessor
From Unreal Wiki, The Unreal Engine Documentation Site
< User:00zX
Revision as of 10:04, 15 February 2011 by 00zX (Talk | contribs) (Created page with '==Including Macro Files== <uscript> class YourPawn extends UTPawn config(YourConfig); `include(YourMacroFile.uci) </uscript> ===Example Macro File=== When compiling with the '…')
Contents
Including Macro Files
class YourPawn extends UTPawn config(YourConfig); `include(YourMacroFile.uci)
Example Macro File
When compiling with the -debug command line switch, the debug macro will then be defined and will switch our blank spaces to config/exec respectively.
`if(`notdefined(Debug)) `define dconf `define dexec `else `define dconf config `define dexec exec `endif
Copy the above template into a blank text document and call the file YourMacroFile.uci
Example of usage
If we want to add a variable thats configurable only when the macro `DevBuild is defined.
class YourPawn extends UTPawn config(YourConfig); `include(YourMacroFile.uci) var `{dconf} bool bCanDodge; function bool Dodge(eDoubleClickDir DoubleClickMove) { if(bCanDodge) return Super.Dodge(DoubleClickMove); else return false; } defaultproperties { `if(`notdefined(Debug)) bCanDodge=True `endif }
YourConfig
[YourPackage.YourPawn] bCanDodge=True
Example of usage
If we want to add a variable that already exists but is not config editable. (PostBeginPlay)
class YourPawn extends UTPawn config(YourConfig); `include(YourMacroFile.uci) `if(`isdefined(Debug)) var `{dconf} float newGroundSpeed; function PossessedBy(Controller C, bool bVehicleTransition) { Super.PossessedBy(C, bVehicleTransition); GroundSpeed = newGroundSpeed; } `endif
Useful Macros
`define LogdFuncN() `logd(GetPackageName()$"."$class.name$"."$GetFuncName(),,'Debug');