The parameters that are passed to the UPROPERTY() macro specify a couple of important pieces of information regarding the variable. In the preceding example, we specified the following:
- EditAnywhere: This means that the property can be edited either directly from the Blueprint, or on each instance of the UClass object as placed
in the game level. Contrast this with the following: - EditDefaultsOnly: The blueprint's value is editable, but it is not editable on a per-instance basis.
- EditInstanceOnly: This would allow editing of the property in the game-level instances of the UClass object, and not on the base blueprint itself.
- BlueprintReadWrite: This indicates that the property is both readable and writable from the blueprints diagrams. UPROPERTY() with BlueprintReadWrite must be public members; otherwise, compilation will fail. Contrast this with the following:
- BlueprintReadOnly: The property must be set from C++ and cannot be changed from the blueprints.
- Category: You should always specify a Category for your UPROPERTY() as it's a good practice to stay organized. The Category determines which submenu the UPROPERTY() will appear under in the property editor. All UPROPERTY() specified under Category=Stats will appear in the same Stats area in the blueprints editor. If no category is specified, the UPROPERTY will appear under the default category, UserProfile (or whatever one called their class).