Search code examples
unreal-engine4unreal-blueprint

How do you set the size of an array that is exposed in Blueprint from within Blueprint?


Is there a way to expose an array of undetermined size to the blueprint editor so that the level/game designer can adjust the size of the array?

In my example, I want an array of gunshot sound effects.

In my header file I have this:

UPROPERTY(EditAnywhere)
USoundBase* MuzzleSound[5];

... but I don't know how to do it without having to already know the size.

Over in BP I want some way to be able to adjust the size to add even more if desired: enter image description here

Is this possible?


Solution

  • You can use a TArray. TArrays are the default array the editor uses within blueprints.

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
        TArray<USoundBase*> MuzzleSound;