|
| 1 | +# Blueprint Macros |
| 2 | + |
| 3 | +The following macros are used to manipulate blueprint functions from C++. |
| 4 | + |
| 5 | +> **Note:** Param names for wrappers must be identical to the names used for the function in UE, and they should then be passed to macros with a `PropertyName` param as shown in `AActor.cpp`. |
| 6 | +
|
| 7 | +This does not apply to macros with the `_CUSTOM` suffix. |
| 8 | + |
| 9 | +With those macros you have to supply both the UE property name as well as the name of your C++ param. |
| 10 | + |
| 11 | +These `_CUSTOM` suffixed macros are useful when the UE property name contains spaces or other characters that aren't valid for a C++ variable. |
| 12 | + |
| 13 | +## Regular macros: |
| 14 | +Intended for normal use by modders. |
| 15 | + |
| 16 | +### `UE_BEGIN_SCRIPT_FUNCTION_BODY`: |
| 17 | +Finds non-native (meaning BP) UFunction by its full name without the type prefixed, throws if not found. |
| 18 | + |
| 19 | + |
| 20 | +### `UE_BEGIN_NATIVE_FUNCTION_BODY`: |
| 21 | +Same as above except for native, meaning non-BP UFunctions. |
| 22 | + |
| 23 | +See: `AActor::K2_DestroyActor` |
| 24 | + |
| 25 | + |
| 26 | +### `UE_SET_STATIC_SELF`: |
| 27 | +Used for static functions, and should be the CDO to the class that the UFunction belongs to. |
| 28 | + |
| 29 | +See: `UKismetNodeHelperLibrary::GetEnumeratorUserFriendlyName.` |
| 30 | + |
| 31 | + |
| 32 | +### `UE_COPY_PROPERTY`: |
| 33 | +Copies the property of the supplied name into the already allocated params struct. |
| 34 | +- Param 1: The name, without quotes, of a property that exists for this UFunction. |
| 35 | +- Param 2: The type that you want the underlying value to be copied as. For example, without quotes, "float" for `FFloatProperty`. |
| 36 | + |
| 37 | + |
| 38 | +### `UE_COPY_PROPERTY_CUSTOM`: |
| 39 | +Copies the property of the supplied name into the already allocated params struct. |
| 40 | +- Param 1: The name, without quotes, of a property that exists for this UFunction. |
| 41 | +- Param 2: A C++ compatible variable name for the property. |
| 42 | +- Param 3: The type that you want the underlying value to be copied as. For example, without quotes, "float" for `FFloatProperty`. |
| 43 | + |
| 44 | + |
| 45 | +### `UE_COPY_STRUCT_PROPERTY_BEGIN`: |
| 46 | +Begins the process of copying an entire struct. |
| 47 | +- Param 1: The name, without quotes, of an ``FStructProperty`` that exists for this UFunction. |
| 48 | + |
| 49 | + |
| 50 | +### `UE_COPY_STRUCT_PROPERTY_CUSTOM_BEGIN`: |
| 51 | +Begins the process of copying an entire struct. |
| 52 | +- Param 1: The name, without quotes, of an ``FStructProperty`` that exists for this UFunction. |
| 53 | +- Param 2: A C++ compatible variable name for the property. |
| 54 | + |
| 55 | + |
| 56 | +### `UE_COPY_STRUCT_INNER_PROPERTY`: |
| 57 | +Copies a property from within an `FStructProperty` into the already allocated params struct. |
| 58 | +- Param 1: The name, without quotes, of the `FStructProperty` supplied to `UE_COPY_STRUCT_PROPERTY_BEGIN`. |
| 59 | +- Param 2: The name, without quotes, of a property that exists in the supplied `FStructProperty`. |
| 60 | +- Param 3: The type that you want the underlying value to be copied as. For example, without quotes, "float" for `FFloatProperty`. |
| 61 | +- Param 4: The name of the C++ variable that you're copying. |
| 62 | + |
| 63 | +See: `AActor::K2_SetActorRotation` |
| 64 | + |
| 65 | + |
| 66 | +### `UE_COPY_STRUCT_INNER_PROPERTY_CUSTOM`: |
| 67 | +- Param 1: The name, without quotes, of the `FStructProperty` supplied to `UE_COPY_STRUCT_PROPERTY_BEGIN`. |
| 68 | +- Param 2: The name, without quotes, of a property that exists in the supplied `FStructProperty`. |
| 69 | +- Param 3: A C++ compatible variable name for the property. |
| 70 | +- Param 4: The type that you want the underlying value to be copied as. For example, without quotes, "float" for `FFloatProperty`. |
| 71 | +- Param 5: The name of the C++ variable that you're copying. |
| 72 | + |
| 73 | + |
| 74 | +### `UE_COPY_OUT_PROPERTY`: |
| 75 | +Copies the out property of the supplied name from the params struct into the supplied C++ variable. |
| 76 | + |
| 77 | +This means the wrapper param (which is named the same as the property supplied) must be a reference, meaning suffixed with a "&". |
| 78 | +- Param 1: The name, without quotes, of a property that exists for this UFunction. |
| 79 | +- Param 2: The type that you want the underlying value to be copied as. For example, without quotes, "float" for `FFloatProperty`. |
| 80 | + |
| 81 | +See: `UGameplayStatics::FindNearestActor` |
| 82 | + |
| 83 | + |
| 84 | +### `UE_COPY_OUT_PROPERTY_CUSTOM`: |
| 85 | +Copies the out property of the supplied name from the params struct into the supplied C++ variable. |
| 86 | +- Param 1: The name, without quotes, of a property that exists for this UFunction. |
| 87 | +- Param 2: A C++ compatible variable name for the property. |
| 88 | +- Param 3: The type that you want the underlying value to be copied as. For example, without quotes, "float" for `FFloatProperty`. |
| 89 | + |
| 90 | +This means the wrapper param (which is named the same as the property supplied) must be a reference, meaning suffixed with a "&". |
| 91 | + |
| 92 | + |
| 93 | +### `UE_COPY_VECTOR:` |
| 94 | +Helper for copying an FVector. Must use `UE_COPY_STRUCT_PROPERTY_BEGIN` first. |
| 95 | +- Param 1: The C++ name, without quotes, of the FVector to copy from. |
| 96 | +- Param 2: The name, without quotes, of the FVector, same as supplied to `UE_COPY_STRUCT_PROPERTY_BEGIN`. |
| 97 | + |
| 98 | + |
| 99 | +### `UE_COPY_STL_VECTOR_AS_TARRAY`: |
| 100 | +Helper for copying a TArray. |
| 101 | +- Param 1: The name, without quotes, of an `FArrayProperty` that exists for this UFunction. |
| 102 | +- Param 2: The C++ type, without quotes, that the TArray holds. For example, without quotes, "float", for `FFloatProperty`. |
| 103 | +- Param 3: The C++ that the contents of the TArray will be copied into. |
| 104 | + |
| 105 | + |
| 106 | +### `UE_CALL_FUNCTION`: |
| 107 | +Performs a non-static function call. All non-out params must be copied ahead of this. |
| 108 | + |
| 109 | + |
| 110 | +### `UE_CALL_STATIC_FUNCTION`: |
| 111 | +Performs a static function call, using the CDO provided by `UE_SET_STATIC_SELF` as the static instance. All non-out params must be copied ahead of this. |
| 112 | + |
| 113 | + |
| 114 | +### `UE_RETURN_PROPERTY`: |
| 115 | +Copies the underlying value that the UFunction returned and returns it. |
| 116 | +- Param 1: The type that you want the underlying value to be copied as. For example, without quotes, "float" for `FFloatProperty`. |
| 117 | + |
| 118 | + |
| 119 | +### `UE_RETURN_PROPERTY_CUSTOM`: |
| 120 | +- Param 1: The type that you want the underlying value to be copied as. For example, without quotes, "float" for `FFloatProperty`. |
| 121 | +- Param 2: The name, without quotes, for the property of this function where the return value will be copied from. |
| 122 | + |
| 123 | + |
| 124 | +### `UE_RETURN_VECTOR`: |
| 125 | +Helper for returning an `FVector`. |
| 126 | + |
| 127 | + |
| 128 | +### `UE_RETURN_STRING`: |
| 129 | +Helper for returning an `FStrProperty`. Converts to `StringType`. |
| 130 | + |
| 131 | + |
| 132 | +### `UE_RETURN_STRING_CUSTOM`: |
| 133 | +Helper for returning an `FStrProperty`. Converts to `StringType`. |
| 134 | +- Param 1: The name, without quotes, for the `FStrProperty` of this function where the return value will be copied from. |
| 135 | + |
| 136 | + |
| 137 | +### `WITH_OUTER`: |
| 138 | +Used for templated C++ types passed to macros, like TArray or TMap. |
| 139 | + |
| 140 | +For example, pass, without quotes, `WITH_OUTER(TMap, FName, int)` instead of `TMap<FName, int>` to all macros. |
| 141 | + |
| 142 | +## Internal macros |
| 143 | + |
| 144 | +These are only used by other macros, or by users of our C++ API if they properly understand the internals of the macros, and this requires preexisting knowledge around how UFunctions work, and you'll likely have to [BPMacros.hpp](https://github.com/Re-UE4SS/UEPseudo/blob/main/include/Unreal/BPMacros.hpp) to understand how to use them properly. |
| 145 | + |
| 146 | +### `UE_BEGIN_FUNCTION_BODY_INTERNAL`: |
| 147 | +Throws if the UFunction doesn't exist, and allocates enough space (on the stack when possible, otherwise the heap) for the params and return value(s). |
| 148 | + |
| 149 | + |
| 150 | +### `UE_COPY_PROPERTY_INTERNAL`: |
| 151 | +Finds the property, and throws if not found. |
| 152 | + |
| 153 | + |
| 154 | +### `UE_COPY_PROPERTY_CUSTOM_INTERNAL`: |
| 155 | +Finds the property with the supplied name, and throws if not found. |
| 156 | + |
| 157 | + |
| 158 | +### `UE_RETURN_PROPERTY_INTERNAL`: |
| 159 | +Finds the property to be used for the return value, throws if not found. |
0 commit comments