Blueprint Basics (2) - Structures and Enumerations

Briefly describe
UE4 in addition to the basic data types, there are some aggregated data types.
Structure : A collection that stores data of the same type or different types.
Enumeration : It is a collection of named integer constants, which can be expressed more intuitively by renaming the integer type.

Structure to
create a structure type

In the content browser, right-click -> Blueprintd -> Structure to create a structure, named Struct

Double-click Struct to open the structure setting interface

Click New Variable to add 5 new variables, set the variable name and variable type respectively, the variable type can be any variable type (basic type, structure, enumeration, class, reference, etc.)

Set the default value of the variable in the structure in Default Values

Create a structure variable
, add the variable sVal, select the Struct type in the Variable Type (the new structure type above), and click Compile

You can also set the initial value of the structure in the default Value section below. The existing initial value is set when the structure is defined.
Access the elements in the structure

First get the variable sVAl, and decompose the structure through the Break Struct node, you can access each element of the structure

output test results

Similarly, if you want to assign a value to a structure, you need to use Make Struct. Modify the value of MemberVar_Str to "structure assignment" and print the modified result

output test results

Enumeration
to create an enumeration type

In the content browser, right-click -> Blueprintd -> enumeration to create an enumeration, named Enum

Double-click Enum to open the enumeration setting interface

Click New, add 3 new elements, set the element name and prompt information respectively

Create an enumeration variable
, add the variable eVal, select the Enum type (the newly created enumeration type above) in the Variable Type, and click Compile

You can also set the initial value of the enumeration in the default Value section below, the default value is the first element in the enumeration,

Click the drop-down box, set the enumeration value, enumerate the value of each element of the integer type, the value of the first element is 0, and then sort from 0, 1, 2.........

Get the enumeration variable and print the enumeration value
Set the default value of the enumeration to EnumeMotor, Get the variable mVal, convert the variable to integer type, and print the output

output result

We can also assign values ​​to enums through Set

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325728544&siteId=291194637