Kategori: C++

UE4: Dumb data containers

Say you need a dumb data container for usage in either Blueprints or C++.

Does your container need functions? Use a UCLASS UOBJECT, otherwise, use USTRUCT.

UCLASS:

  1. From the editor, create a new C++ class, Show All, choose UObject
  2. Set the following specificers for UCLASS and UPROPERTY in the header file:
UCLASS(BlueprintType)
class x_API UMyObject: public UObject
{
	GENERATED_BODY()
	
public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	MyProperty* Property;	

	UFUNCTION(BlueprintCallable)
	void MyFunction();

USTRUCT:

  1. Create an Empty C++ class from the editor
  2. Edit the header file:
USTRUCT(BlueprintType)
struct FMyStruct
{
	GENERATED_STRUCT_BODY()
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	MyProperty* Property;	

C++ ”Unable to resolve identifier” error in NetBeans 8.1 (Gnu Compiler Collection)

There’s an infuriating bug (?) in NetBeans with C code completion (at least if you’re using the GNU Compiler Collection), where you can end up with erroneous unable to reslove identifier-hints even though the project will compile and run perfectly fine.
To prevent it, set both your C and C++ compiler to the same standard, on every C/C++ project.


(Project > Properties)