-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Welcome to the Blueprint Component Reference Plugin wiki!
Blueprint Component Reference
provides a universal way of referencing actor components during design time with component picker UI and rich customization.
Blueprint Component Reference
can be used as a single, array, set or map variable in following scenarios:
- Variable directly located in Actor Class or Blueprint.
UCLASS()
class AMyActor : public AActor
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FBlueprintComponentReference SingleComponentReference;
};
- Variable indirectly located in Actor Class or Blueprint.
UCLASS()
class UDemoComponent : public USceneComponent
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FBlueprintComponentReference AlsoAValidProperty;
};
USTRUCT()
struct FRotatingPointsDesc
{
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta=(AllowedClasses="/Script/Demo.AttachPointComponent"))
FBlueprintComponentReference AttachPoint;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
float RotationSpeed = 0.3f;
};
UCLASS()
class AMyActor : public AActor
{
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
TObjectPtr<UDemoComponent> DemoComponent;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
TArray<FRotatingPointsDesc> RotatingPoints;
};
- Variable outside of Actor Blueprint or Class with explicit
ActorClass
parameter
UCLASS()
class UDecorationType : public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta=(ActorClass="/Script/Demo.PlayerCharacter", AllowedClasses="/Script/Demo.AttachPointComponent"))
FBlueprintComponentReference Target;
};
Component picker does support variety of filtering parameters:
- Filtering by component class/interface with
AllowedClasses
andDisallowedClasses
parameters - Filtering by component creation method with
ShowNative
,ShowBlueprint
,ShowInstanced
,ShowHidden
,ShowEditor
parameters
To acquire pointer to component referenced by Blueprint Component Reference
an Actor search context is needed.
In Code it is done with GetComponent
function call, in Blueprints with Get Referenced Component
or Find Referenced Component
nodes.
void AMyActor::SomeFunction()
{
if (UMyComponent* Component = Reference.GetComponent<UMyComponent>(/* Search Context */ this))
{
Component->PerformAction();
}
}
There are several ways to install the plugin: from GitHub and from Marketplace (coming soon).
- Download source code archive from main or
Releases
page - Unpack the contents into "YourProjectFolder/Plugins/BlueprintComponentReferencePlugin" (create if missing)
- Activate plugin in editor
Plugins
menu
Plugin provides following Blueprint APIs:
- Component Search is performed with
Get Referenced Component
,Find Referenced Component
,Get Referenced Components
nodes. - Component Reference state can be checked with
Is Valid Component Reference
,Is Null Component Reference
nodes. - Equality and ToString conversion nodes.
All plugin primary functions located in BlueprintComponentReference
module BlueprintComponentReference.h
file.
To add plugin features in project following steps are necessary:
- Enable
Blueprint Component Reference Plugin
in Plugin Settings - Add
BlueprintComponentReference
module dependency in appropriateBuild.cs
file - Use
BlueprintComponentReference.h
header file for theFBlueprintComponentReference
type
Component selection rules and other traits can be specified with metadata specifiers. Latest list of specifiers can be found here
More examples can be found in BlueprintComponentReferenceTests
module.
Similar to engine component reference implementation FBlueprintComponentReference
does not provide internal cache and each call of GetComponent will do resolve/search.
When repeated component search is an issue there are at least two ways to avoid repeated component search:
- caching search result separately
- using
TCachedComponentReference
helper that wrapsFBlueprintComponentReference
with a weak object pointer to found component.