c++unreal-engine4unreal-engine5

Can't understand Unreal engine C++ function type


I am new to C++ Unreal.

UFUNCTION()
int32 AddToInventory(AInventoryActor* ActorToAdd);

in this code i cant understand what does "int32" mean?

UFUNCTION()
AddToInventory(AInventoryActor* ActorToAdd);

this part of the code is understandable: there is a function itself and its argument. May be int32 there means a type of the argument, but it is unlikely to be true. Sorry if i have done some mistakes in text, english is not my first language


Solution

  • Per Unreal's documentation:

    UFunctions
    https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/GameplayArchitecture/Functions/

    A UFunction is a C++ function that is recognized by the Unreal Engine 4 (UE4) reflection system. Any UObject or Blueprint function library can declare a member function as a UFunction by placing the UFUNCTION macro on the line above the function declaration in the header file. The macro will support Function Specifiers to change how UE4 interprets and uses a function.

    UFUNCTION([specifier1=setting1, specifier2, ...], [meta(key1="value1", key2, ...)])
    ReturnType FunctionName([Parameter1, Parameter2, ..., ParameterN1=DefaultValueN1, ParameterN2=DefaultValueN2]) [const]; 
    

    So, in your case...

    UFUNCTION() is a macro that marks the function in the Reflection system.

    int32 is the return type, a 32bit integer.

    AddToInventory is the function name.

    AInventoryActor* ActorToAdd is an input parameter.