C++ Essentials
Compiling
Header Files
The editor must be closed before compiling after modification of a header file.
Unreal has serialization and update steps to ensure that downstream blueprints and editor information are up to date.
These will fail and potentially cause issues if done while the editor is open.
My workflow is to update, save, close the editor, and then run from the IDE again. A build will be triggered that will do the compilation.
Be warned that running a "Live Coding" Hot Reload will affect this too.
Live Coding
You can Hot Reload while the editor is running to update your C++ code.
This is useful for compiling and updating your Source Files.
Refreshing
Sometimes there is an issue with the syncing between the editor, IDE, and files.
These can range from errors on build or a "missing file."
Usually, refreshing the solution or regenerating the project files will solve the issues.
Class Specifiers
Each Unreal Class definition will have the UCLASS() macro above it.
Specifiers can be added to modify class behavior.
| Name | Description |
|---|---|
| Abstract |
Declares the class as an "abstract base class". |
| Blueprintable, BlueprintType |
Allows the creation of blueprints and use of this class as a variable. |
Function Specifiers
A UFUNCTION() macro can be added to function definitions to expose them to editor and engine segments.
Without the macro, it works like a standard C++ function.
| Name | Description |
|---|---|
| BlueprintCallable |
The function can be executed in a Blueprint or Level Blueprint graph. |
| BlueprintPure |
The function does not affect the owning object in any way and can be executed in a Blueprint or Level Blueprint graph. |
Property Specifiers
A UPROPERTY() macro can be added to property definitions to expose them to editor and engine segments.
Without the macro, it works like a standard C++ property.
| Name | Description |
|---|---|
| BlueprintReadWrite |
This property can be read or written from a Blueprint. |
| BlueprintReadOnly |
This property can be read by Blueprints, but not modified. |
| EditDefaultsOnly |
Indicates that this property can be edited by property windows, but only on archetypes. |
| EditInstanceOnly |
Indicates that this property can be edited by property windows, but only on instances, not on archetypes. |
| EditAnywhere |
Indicates that this property can be edited by property windows, on archetypes and instances. |
| VisibleAnywhere |
Indicates that this property is visible in all property windows, but cannot be edited. |
| VisibleDefaultsOnly |
Indicates that this property is only visible in property windows for archetypes, and cannot be edited. |
| VisibleInstanceOnly |
Indicates that this property is only visible in property windows for instances, not for archetypes, and cannot be edited. |
Functions
Output Pins
Using a Reference Operator in a function parameter will designate it as an output pin in Blueprints.
