Using Structs

Get started using Structs with this short guide


Structs (or UStructs) are data structures that help you organize and manipulate related properties. By using structs, you can create custom variable types to help organize your project. This guide will help you set up structs, and give some insight into how they can be customized.

Implementing Structs

  1. Open the header (.h) file where you want to define your struct.

  2. Define your C++ struct and add the USTRUCT macro before it, including any UStruct Specifiers your struct needs.

  3. Add the GENERATED_BODY macro to the top of your struct.

  4. You can now tag the struct's member variables with UPROPERTY to make them visible to UE's reflection system and Blueprint Scripting.

    1. Check out this list of UProperty Specifiers to see how the property can behave within various aspects of the Engine and Editor.


struct FMyStruct

    //~ The following member variable will be accessible by Blueprint Graphs:
    // This is the tooltip for our test variable.
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Test Variables")
    int32 MyIntegerMemberVariable;

    //~ The following member variable will be not accessible by Blueprint Graphs:
    int32 NativeOnlyMemberVariable;

    * This UObject pointer is not accessible to Blueprint Graphs, but
    * is visible to UE4's reflection, smart pointer, and garbage collection
    * systems.
    UObject* SafeObjectPointer;

Additional Information

Here are some helpful hints and things to remember when using Structs:

  1. UStructs can use UE's smart pointer and garbage collection systems to prevent UObjects from being removed by garbage collection.

  2. Structs are different from UObjects, and because of this Structs are best used for simple data types.

    1. For more complicated interactions within your project, you may want to make a UObject or AActor subclass instead.

  3. UStructs ARE NOT considered for replication.

    1. UProperty variables ARE considered for replication.

  4. UE has the ability to automatically create Make and Break functions for Structs.

    1. Make appears for any UStruct with the BlueprintType tag.

    2. Break appears if you have at least one BlueprintReadOnly or BlueprintReadWrite property in the UStruct.

    3. The pure node that Break creates will provide one output pin for each property tagged as BlueprintReadOnly or BlueprintReadWrite.

Select Skin
언리얼 엔진 문서의 미래를 함께 만들어주세요! 더 나은 서비스를 제공할 수 있도록 문서 사용에 대한 피드백을 주세요.
설문조사에 참여해 주세요

새로운 언리얼 엔진 4 문서 사이트에 오신 것을 환영합니다!

문서 사이트에 대한 의견을 모을 수 있는 피드백 시스템을 포함해서 여러가지 새로운 기능을 준비하고 있습니다. 아래 Documentation Feedback 포럼(영문) 또는 언리얼 엔진 네이버 공식 카페(한글) 중 편하신 곳에 의견이나 문제점을 알려 주세요.

새 시스템이 준비되면 알려 드리겠습니다.

네이버 카페
공식 포럼