C++ Derived Blueprint: TArray<> not working in standalone window

I have a C++ gamemode in which i declare the following TArray<>:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Collection)
TArray<ASpriteActor*> Tiles;

I also have a Blueprint derived from this class.
In this Blueprint i have a function that spawns ASpriteActors and adds them to the array.
But for some reason this only works in Editor and not in Separate Windows (e.g. mobile preview, packaged game, etc.). I don’t get any error or anything, the function just does not spawn the actors.

The funny thing is that it DOES work when i create a separate array in the blueprint and use it instead of the c++ array. I may be missing some required UPROPERTY or something, but i have not found anything as to why this problem occurs.

I hope some of you can give me more insight, thanks in advance :slight_smile:

Wiring Test instead of Tiles works in-editor as well as in other windows.

Nevermind, my error was in another function. Apparently GetViewPort size returned 0 sincethe HUD was not rendered in time.

Hey Neodymus,

I’ve attempted to reproduce your issue, but I’m not seeing the same results. Here’s how I’m populating my array. For my test, I’ve used just the base Actor class. Not all of the code is necessary, but I put in some extra checks and logging just for testing purposes.

MyActor.cpp:

void AMyActor::BeginPlay()
{
	Super::BeginPlay();

	for (int counter = 0; counter < 5; counter ++)
	{
		UWorld* World;

		World = GetWorld();

		if (World)
		{
			AActor* TempActor;

			TempActor = World->SpawnActor<AActor>();

			Tiles.Add(TempActor);
		}

		AActor* ArrayActor = Tiles[counter];

		UE_LOG(LogTemp, Warning, TEXT("Tiles[%d] = %s"), counter, *ArrayActor->GetName());

		GEngine->AddOnScreenDebugMessage(-1, 2.0, FColor::Emerald, (TEXT("Tiles[%d] = %s"), counter, *ArrayActor->GetName()), true, FVector2D(2,2));
	}
	
}

I also did as you did and used a blueprint with the setup pictured below and I’m seeing it working great in Standalone as well:

If you could provide your blueprint as well as your code or point out the steps I’m missing on my end that’d be great.

Thanks