UE4 c++ UStruct syntax
Vložit
- čas přidán 22. 08. 2024
- Quick tutorial showing the set-up of a blueprint friendly UStruct in c++
Syntax for copy pasting: (Note I took out the TEnumAsByte entry as descriptions don't allow Brackets)
USTRUCT(BlueprintType)
struct FWeaponData
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Struct")
ACharacter* player;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Struct")
int32 ammoCount;
};
Just a quick headsup for people who may be getting VS editor errors with the #include "X.generated.h" lines etc, you have to close VS, hop over to the Unreal Engine Project File, right click and select 'Generate Visual Studio project files'.
Great tutorial btw ;)
If you watch it in 2020, dont forget to add #include "ClassName.generated.h", close editor and rebuild to get it work
Thanks, dude.
No worries at all! Glad you found it useful.
grazie
cool video, is there a way to set the struct members in the source file?
You can create and edit it like any normal c++ struct from code, there's plenty of other tutorials which show the syntax for doing that. This video was specific to getting it to play nicely with blueprint sorry!
you say there's plenty of tutorials but there's not plenty about editing structs in c++; only declaring them... no worries, we have blueprint for that part.
how did you get your intellisense to work? mine pops 99999999999 errors, despite installing the intellisense ue4 plugin.
ah nvm as soon as i included the generated header, everything was fixed!