-
Notifications
You must be signed in to change notification settings - Fork 4
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 or map value 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
ActorClassparameter
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 multiple filtering parameters:
- Filtering by component class/interface with
AllowedClassesandDisallowedClassesparameters - Filtering by component creation method with
ShowNative,ShowBlueprint,ShowInstanced,ShowHidden,ShowEditorparameters
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 (UMyActorType* Component = Reference.GetComponent<UMyActorType>(/* 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
Releasespage - Unpack the contents into "YourProjectFolder/Plugins/BlueprintComponentReferencePlugin" (create if missing)
- Activate plugin in editor
Pluginsmenu
Plugin provides following Blueprint APIs:
- Component Search is performed with
Get Referenced Component,Find Referenced Component,Get Referenced Componentsnodes. - Component Reference state can be checked with
Is Valid Component Reference,Is Null Component Referencenodes. - 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 Pluginin Plugin Settings - Add
BlueprintComponentReferencemodule dependency in appropriateBuild.csfile - Use
BlueprintComponentReference.hheader file for theFBlueprintComponentReferencetype
FBlueprintComponentReference type can be used as a single property, array or map value.
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
TCachedComponentReferencehelper that wrapsFBlueprintComponentReferencewith a weak object pointer to found component.