Professional Documents
Culture Documents
2 UENUM()
1
1.5 UPROPERTY() UPROPERTY(EditAnywhere, Category="Category|Sub")
bool BoolProperty;
BlueprintAssignableMulticast Delegates only. Exposes UPROPERTY(BlueprintReadOnly, AdvancedDisplay)
property for assigning in Blueprints TSubclassOf<UStaticMesh> AdvancedMeshClass;
UPROPERTY(meta=(EditCondition="BoolProperty"))
BlueprintCallable Multicast Delegates only. Property
uint16 ConditionalInt;
property for calling in Blueprints
UPROPERTY(meta=(BitMask, BitMaskEnum="EMyEnum"))
BlueprintReadOnly This property can be read by
int32 BitFlags;
blueprints, but not modified
UPROPERTY(meta=(ClampMin="3", ClampMax="4"))
BlueprintReadWrite This property can be read or written
float myFloat;
from a blueprint
Category Specifies the category of the prop-
erty within the Editor. Supports 1.6 USTRUCT()
sub-categories separated by ”|” BlueprintType Structs with this attribute can be
EditAnywhere Indicates that this property can used as type inside Blueprints. Make
be edited via property windows, and Break nodes get automatically
archetypes and instances within the generated.
Editor USTRUCT(BlueprintType)
EditDefaultsOnly Indicates that this property can be struct MyStruct {
edited by property windows, but // ...
only on archetypes. This operator is }
incompatible with the Visible* spec-
ifiers 1.7 Delegates
EditFixedSize Indicates that elements of an array
can be modified in Editor, but its Delegates allow to call variable functions via a type-safe way.
size cannot be changed There are 3 big types of delegates:
EditInstanceOnly Indicates that this property can be • Single-cast Delegates, which can have a single function
edited by property windows, but target, declared with DECLARE_DELEGATE_
only on instances, not on archetypes
• Multi-cast Delegates, which can have multiple function
Transient Property is transient: shouldn’t be
targets, declared with DECLARE_MULTICAST_DELEGATE_
saved, zero-filled at load time
VisibleAnywhere Indicates that this property is visi- • Dynamic Multicasts, which can be serial-
ble in property windows, but cannot ized, and functions can be found by name,
be edited at all declared with DECLARE_DYNAMIC_DELEGATE_ or
VisibleDefaultsOnly Indicates that this property is only DECLARE_DYNAMIC_MULTICAST_DELEGATE_
visible in property windows for
All Delegate macros have the syntax:
archetypes, and cannot be edited
_DELEGATE_<Num>Params(Name,Param1Type,Param2Type,...)
VisibleInstanceOnly Indicates that this property is only
or for functions with return value:
visible in property windows for in-
DECLARE_DELEGATE_RetVal(RetValType, Name)
stances, not for archetypes, and can-
Code example:
not be edited
AdvancedDisplay Moves the property into the Ad- DECLARE_MULTICAST_DELEGATE(VoidDelegate)
vanced dropdown in the Details DECLARE_DELEGATE_OneParam(IntParamDelegate, int32)
panel within the Editor DECLARE_DELEGATE_TwoParams(MyDelegate, int32, AActor*)
NoClear Hides the clear and browse button DECLARE_DELEGATE_RetVal_OneParam(int, Delegate2, uint8)
in the editor for this property.
EditCondition The property can only be edited in void MyFunc;
(Meta) Editor if the specified bool Property void MyFunc2(int32);
is true. Use ! to invert logic (so
you can only edit property if bool is VoidDelegate Del1;
false). //Somewhere in func body
BitMask (mMeta) Change the value of this property in Del1.Add(this, FName("MyFunc")); //Add MyFunc
the Editor using a BitMask, which Del1.Broadcast(); //Call all bound functions
means you can select the value of
each single bits. Use BitMask to IntParamDelegate Del2;
specify a Enum, which entries will Del2.Add(this, FName("MyFunc2)); //Bind MyFunc2
be used to name each bit. Del2.ExecuteIfBound(10); //Call MyFunc2
ClampMax / Use this on float or int property, to
ClampMin (Meta) specify a maximum/minimum, that
can be entered for this property in
2 Useful Console commands
the Editor • Show Collision: Show collision components in game.
MakeEditWidget Use this on a Transform or Rotator
(Meta) property, and the property value can • ToggleDebugCamera: Switch to a separate camera,
be changed using a widget inside the which you can move in world freely and shows some addi-
editor viewport. tional debug infos.
2
• HighResShot [number]: Makes a screen shot with [num- auto FirstActor = ActorArray[0]
ber] times your normal screen resolution. Instead of [num- //Iterate over all Actor in Array
ber] you can provide a resolution the screenshot should for (AActor* Actor : ActorArray) {
have. Actor->SomeFunc();
}
• [CVar] ?: Add a ? after a CVar name and a description
about the CVar will be shown. • TMap: A container, where every element has a key (of
any type), via which you identify every element. Similar to
• DumpConsoleCommands: Prints a list of all available std::map
console commands and CVars.
TMap<int32, FString> StringMap;
• slomo [float]: Slow down or speed up the game. slomo
StringMap.Add(4, TEXT("Foo"));
1.0 is default. slomo 1.5 is faster than normal, slomo 0.5 is
StringMap.Add(-1, TEXT("Bar"));
slower.
//Iterate over all Pairs
• open [mapname]: Load and opens the map with the given for (auto& pair : StringMap)
name. {
pair.Key; //Gets the key of the pair
• help: Opens a page in browser which, lists all console com- *pair.Value; //Gets the value of pair
mands and variables with a description. Searching and filter }
for specific commands is possible.
• TSet: A (fast) container to store unique elements without
order. Similar to C++’s std::Set
3 Classes and Functions
TSet<int32> mySet;
3.1 Base Gameplay Classes mySet.Add(3); //mySet = [3]
mySet.Add(5); //mySet = [3,5]
• UObject: The base class, all classes, that should be used mySet.Add(3); //mySet = [3,5]
within C++ must extend. The name of child classes should //Only one 3 can be added to mySet
start with U (e.g. UMyNewClass).
• TSubclassOf: When you define a UProperty with the type
• AActor: Actor is the base class for all objects, that can TSubclassOf<UMyObject>, the editor allows you only to
be placed in a level. An Actor can has various Components. select classes, which are derived from UMyObject.
Child classes should start with A (e.g AMyNewActor).
UPROPERTY(EditAnywhere)
• APawn: The base class, for all actors, that should be
TSubclassOf<AActor> ActorType;
controled by players or AI.
• FName: FNames provide a fast possibility to reference to
• ACharacter: Characters are Pawn, which has a mesh
things via a name. FNames are case-insensitive and can
collision and movement logic. They represent physical
not be manipulated (they are immutable).
characters in the game world and can use CharacterMove-
mentComponent for walking, flying, jumping and swiming • FText: FText represents a string that can be displayed to
logic. user. It has a built in system for localization (so FTexts
can be translated) and are immutable.
• UActorComponent: The base class for all actor compo-
nents. Components defines some reusable behavior, that • FString: FString is the only class that allows manipula-
can be added to different actors. tion. FStrings can be searched modified and compared, but
this makes FStrings less performant than FText or FName.
• USceneComponent: An Actor Component, which has a
transform (position and rotation) and support for attache-
ments.
3.3 Useful Functions and snippets
• UE LOG(): This functions allows to print message to the
• UPrimitiveComponent: A SceneComponent which can UE Log or the Output Log in the Editor. You can set a
show some kind of geometry, usable for rendering and/or category (you can use LogTemp for temporal usage) and
collision. Examples for this type are StaticMeshComponent, verbosity (like Error, Warning or Display). If you want
SkeletalMeshComponent, or the ShapeComponents. to output a variable, you can use printf syntax. Usage
Example:
3.2 Datastructures and Helpers
//Print Test to console
• TArray: The mostly used container in UE4. The objects UE_LOG(LogTemp, Warning, TEXT("Test"));
in it have a well-defined order, and functions are provided to //Print the value of int n and a string
create, get, modify or sort the elements. Similar to C++’s UE_LOG(LogTemp, Display, TEXT("n=%d"), n);
std::vector. You can iterate over the element like this: UE_LOG(LogTemp, Error, TEXT("%s"), MyString);
3
GEngine->AddOnScreenDebugMessage(-1, 5.f, • check(): If the expression inside check() is false, the execu-
FColor::Red, TEXT("5 second Message")); tion will be halted. The expression is only evaluated, when
//Use FString, if you want to print vars DO_CHECK is set. If you need that the expression is always
GEngine->AddOnScreenDebugMessage(-1, 5.f, evaluated, then use verify().
FColor::Red,
FString::Printf(TEXT("x: %f, y: %f"), x, y)); check(OneProperty == 1);
verify(ImportantCall() != nullptr);
• NewObject(): NewObject() creates a new UObject with
the specific type. Objects created using NewObject() are • checkf(): Behaves like check(), but additional debug info
not visible to the Editor, if you need that, use CreateDe- is printed. verifyf() works analogous.
faultSubObject() instead. Usage example:
• checkNoEntry(): You can mark code path that should
auto RT = NewObject<UTextureRenderTarget2D>(); never be executed with this assertion. If it is still be called,
the execution is halted.
• CreateDefaultSubobject(): This function creates a new
named UObject with the specific type in the context of the switch(Property) {
current actor. Created objects are visible to the Editor, case EEnum:Val1:
but this function can only be used in constructor. Usage return 1;
example: default:
checkNoEntry();
auto Mesh = CreateDefaultSubobject }
<UStaticMeshComponent>(FName("Mesh"));
• unimplemented(): Use this assertions, on functions that
• LoadObject(): This function loads an objects from a are yet unimplemented or must be overridden to work prop-
specific asset. Usage example: erly.