0% found this document useful (0 votes)
124 views2 pages

Unreal Engine 4 C++ Cheat Sheet: (C) J. B Ohmer, March 2018 Licensed Under CC BY-NC-SA 4.0

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

Unreal Engine 4 C++ UPROPERTY(EditAnywhere, Category="Category|Sub")

bool BoolProperty;
Cheat Sheet UPROPERTY(BlueprintReadOnly, AdvancedDisplay)
TSubclassOf<UStaticMesh> AdvancedMeshClass;
(C) J. Böhmer, March 2018 UPROPERTY(meta=(EditCondition="BoolProperty"))
uint16 ConditionalInt;
Licensed under CC BY-NC-SA 4.0
Version 1.0 1.2 UCLASS()
Abstract An class that is marked as abstract can
1 Reflection System not be placed or instanced during runtime.
This is especially useful for classes, that
1.1 UPROPERTY() does not provide functionality on their own
and must be inherited and modified for
BlueprintAssignable Multicast Delegates only. Ex- meaningful usage.
poses property for assigning in Blueprintable Classes marked with this attribute can be
Blueprints used as a base class for creating Blueprints.
BlueprintCallable Multicast Delegates only. Prop- On Default this is deactivated. The at-
erty property for calling in tribute is inherited by child classes, use
Blueprints NotBlueprintable on childs to disable this.
BlueprintReadOnly This property can be read by BlueprintType Classes with this attribute can be used as
blueprints, but not modified variable type in Blueprints.
BlueprintReadWrite This property can be read or writ- Placeable Classes marked as Placable, can be cre-
ten from a blueprint ated and placed in a level, UI Scene or
Category Specifies the category of the prop- Blueprint via the Editor. The flag is inher-
erty within the Editor. Supports ited by all child classes, use NotPlacable
sub-categories separated by ”|” on child to disable this.
EditAnywhere Indicates that this property can
be edited via property windows, UCLASS(Blueprintable)
archetypes and instances within class MyClass : public UObject {
the Editor //Class code ...
EditDefaultsOnly Indicates that this property can }
be edited by property windows,
but only on archetypes. This op- 1.3 UFUNCTION()
erator is incompatible with the
Visible* specifiers BlueprintAuthorityOnly This function will not execute
EditFixedSize Indicates that elements of an ar- from Blueprint code if running
ray can be modified in Editor, but on something without network
its size cannot be changed authority
EditInstanceOnly Indicates that this property can BlueprintCosmetic This function is cosmetic-only
be edited by property windows, and will not run on dedicated
but only on instances, not on servers
archetypes Blueprint- This function is designed to be
Transient Property is transient: shouldn’t ImplementableEvent overriden by a blueprint. Dont
be saved, zero-filled at load time provide a body for this function
VisibleAnywhere Indicates that this property is vis- in C++.
ible in property windows, but can- BlueprintNativeEvent This function is designed to
not be edited at all be overriden by a blueprint,
VisibleDefaultsOnly Indicates that this property is but also has a native im-
only visible in property windows plementation. Provide
for archetypes, and cannot be a body named [Function-
edited Name] Implementation
VisibleInstanceOnly Indicates that this property is BlueprintPure This function has no side effects
only visible in property windows on the object. Useful for ”Get”
for instances, not for archetypes, functions. Implies Blueprint-
and cannot be edited Callable
AdvancedDisplay Moves the property into the Ad- BlueprintCallable This function can be called from
vanced dropdown in the Details Blueprints and/or C++.
panel within the Editor Category Specifies the category of the
EditCondition (Meta) The property can only be edited function within the Editor. Sup-
in Editor if the specified bool ports sub-categories separated
Property is true. Use ! to in- by ”|”
vert logic (so you can only edit Exec This function is callable from the
property if bool is false). Console CLI.

1
UFUNCTION(Exec) • FString: FString is the only class that allows manipula-
void ConsoleCommand(float param); tion. FStrings can be searched modified and compared, but
UFUNCTION(BlueprintPure) this makes FStrings less performant than FText or FName.
static FRotator MakeRotator(flat f);
UFUNCTION(BlueprintImplementableEvent) 2.3 Useful Functions
void ImportantEvent(int param);
• UE LOG(): This functions allows to print message to the
UE Log or the Output Log in the Editor. You can set a
2 Classes and Functions category (you can use LogTemp for temporal usage) and
verbosity (like Error, Warning or Display). If you want
2.1 Base Gameplay Classes to output a variable, you can use printf syntax. Usage
• UObject: The base class, all classes, that should be used Example:
within C++ must extend. The name of child classes should
//Print Test to console
start with U (e.g. UMyNewClass).
UE_LOG(LogTemp, Warning, TEXT("Test"));
• AActor: Actor is the base class for all objects, that can //Print the value of int n and a string
be placed in a level. An Actor can has various Components. UE_LOG(LogTemp, Display, TEXT("n=%d"), n);
Child classes should start with A (e.g AMyNewActor). UE_LOG(LogTemp, Error, TEXT("%s"), MyString);

• APawn: The base class, for all actors, that should be • AddOnScreenDebugMessage(): If you want to print a
controled by players or AI. debug message directly to the screen you can use AddOn-
ScreenDebugMessage() from GEngine. You can specify a
• ACharacter: Characters are Pawn, which has a mesh
key, displaying time and display color. A message overrides
collision and movement logic. They represent physical
an older message with the same key. Usage example:
characters in the game world and can use CharacterMove-
mentComponent for walking, flying, jumping and swiming
GEngine->AddOnScreenDebugMessage(-1, 5.f,
logic.
FColor::Red, TEXT("5 second Message"));
• UActorComponent: The base class for all actor compo- //Use FString, if you want to print vars
nents. Components defines some reusable behavior, that GEngine->AddOnScreenDebugMessage(-1, 5.f,
can be added to different actors. FColor::Red,
FString::Printf(TEXT("x: %f, y: %f"), x, y));
• USceneComponent: An Actor Component, which has a
transform (position and rotation) and support for attache- • NewObject(): NewObject() creates a new UObject with
ments. the specific type. Objects created using NewObject() are
not visible to the Editor, if you need that, use CreateDe-
• UPrimitiveComponent: A SceneComponent which can
faultSubObject() instead. Usage example:
show some kind of geometry, usable for rendering and/or
collision. Examples for this type are StaticMeshComponent,
auto RT = NewObject<UTextureRenderTarget2D>();
SkeletalMeshComponent, or the ShapeComponents.
• CreateDefaultSubobject(): This function creates a new
2.2 Datastructures and Helpers named UObject with the specific type in the context of the
current actor. Created objects are visible to the Editor,
• TArray: The mostly used container in UE4. The objects
but this function can only be used in constructor. Usage
in it have a well-defined order, and functions are provided to
example:
create, get, modify or sort the elements. Similar to C++’s
std::vector. You can iterate over the element like this: auto Mesh = CreateDefaultSubobject
<UStaticMeshComponent>(FName("Mesh"));
for (AActor* Actor : ActorArray) {
Actor->SomeFunc(); }
• LoadObject(): This function loads an objects from a
• TMap: A container, where every element has a key (of specific asset. Usage example:
any type), via which you identify every element. Similar to
auto Mesh = LoadObject<UStaticMesh>(nullptr,
std::map
TEXT("StaticMesh’/Asset/Path/Mesh.Mesh’");
• TSet: A (fast) container to store unique elements without
order. Similar to C++’s std::Set • Cast(): Casts an object to the given type. Returns nullptr
if the object is not castable to this type. The object that
• TSubclassOf: When you define a UProperty with the type should be casted, must be based on UObject, to work prop-
TSubclassOf<UMyObject>, the editor allows you only to erly. Usage example:
select classes, which are derived from UMyObject.
AActor* Actor = Cast<AActor>(Other);
• FName: FNames provide a fast possibility to reference to
if(Actor != nullptr) {
things via a name. FNames are case-insensitive and can
/* do something */ }
not be manipulated (they are immutable).
• FText: FText represents a string that can be displayed to
user. It has a built in system for localization (so FTexts
can be translated) and are immutable.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy