Blog

Technical thoughts, troubleshooting, and development notes.

Blog/UE Development

Unreal Blueprint parameters: references and display names

A C++ reference parameter may appear as a different Blueprint pin direction than expected. Type, `const` and metadata all matter. These UE5 reflected

Back
This page's table of contents

Less Common Function Parameters

Blueprint Parameter References

UFUNCTION(BlueprintCallable)
static void DoSomething(UPARAM(ref) TArray<int> &InOutArray);

By declaring a reference parameter with UPARAM(ref) in a function, you can pass a reference to a Blueprint object and modify it in C++. The UPARAM parameter must be in the first parameter position.

Rename Blueprint Parameters

UFUNCTION(BlueprintCallable)
void MakeDog(
  UPARAM(DisplayName = "Years (dog years)") float Years,
  UPARAM(DisplayName = "Fur Color") FLinearColor Color);

Allow Abstract Values as Input

UFUNCTION(BlueprintCallable, Category = "Composure", meta = (DeterminesOutputType = "OutputType"))
UCompositingElementOutput* FindOutputPass(UPARAM(meta = (AllowAbstract = "true"))TSubclassOf<UCompositingElementOutput> OutputType, FName OptionalPassName = NAME_None);

Class Restrictions

UFUNCTION(unreliable, client, BlueprintCallable, Category="Game|Feedback")
void ClientSpawnGenericCameraLensEffect(UPARAM(meta=(MustImplement ="CameraLensEffectInterface")) TSubclassOf<class AActor>  LensEffectEmitterClass);

Passing Lambda Functions

Example

void FXvpInputActionSet::ForEachAction(const TFunctionRef<void(FXvpInputActionBase*)>& Fn)
	{
	for (auto Property = GetStructType()->PropertyLink; Property; Property = Property->PropertyLinkNext)
		{
			if (const auto StructProperty = CastField<FStructProperty>(Property))
			{
			const auto ActionPtr = StructProperty->ContainerPtrToValuePtr<FXvpInputActionBase>(this);
				Fn(ActionPtr);
			}
		}
	}