The ExposeOnSpawn
specifier exposes a property as a node pin when constructing the containing class. This allows for terse construction in Blueprints using only a single construct node, as opposed to first constructing the object and then setting properties individually. For example, consider the following property contained within a UserWidget
class:
UPROPERTY(BlueprintReadOnly, meta=(ExposeOnSpawn="true"))
UTowerAction* Action;
When the UserWidget
class is created, the Action
property is exposed for initialization:
Notwithstanding its name, this specifier can be applied to properties of both Actors
(which are spawned) and Objects
(which are constructed).
Given that the decorated property is exposed on a Blueprint node, this specifier must be coupled with either of the BlueprintReadOnly
or BlueprintReadWrite
specifiers. If it is marked BlueprintReadOnly
, the property can still be initialized on spawn but cannot be written within Blueprints thereafter.
The behavior of this specifier is unclear with respect to Delegates
. For further information, see this article and UE-44977.
To achieve similar behavior when spawning actors or constructing objects from C++, check out SpawnActorDeferred
.