TArray Struct blueprint issue

I created a static function in a blueprint function library class that returns a TArray of a custom struct I made in C++. In a blue print I am trying to iterate over that array with a for each loop. When I initially setup the blueprint it works perfectly, however, if I restart the editor the blueprint breaks. See picture below:

In that picture the input type of the for each loop changes from Array of Active Game Data Structures when it is working initially to Array of Structures when it restarts and is broken. If I refresh the nodes it compiles broken again but if I break the connection between the return of the array and the for each loop and reconnect it works, this is because the type turns back to Array of Active Game Data Structures.

The related code:

#include "CoreMinimal.h"
#include "ActiveGameData.generated.h"

/**
 * 
 */
USTRUCT(BlueprintType)
struct TACTICALSUPREMACY_API FActiveGameData
{
	GENERATED_BODY()
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test")
	FString MapFileName;
};
TArray<FActiveGameData> UActiveGames::GetActiveGames(const FString SuppliedUserID)
{
	TSharedPtr<FJsonObject> Response;

	Response = SendHTTP(Url(SuppliedUserID), Verb());
	TArray<FActiveGameData> DeserializedGames;
	if (Response.IsValid() && !Response->GetArrayField("games").IsEmpty())
	{
		TArray<TSharedPtr<FJsonValue>> RawGames = Response->GetArrayField("games");
		for (int i = 0; i < RawGames.Num(); i++) {
			FActiveGameData Data;
			Data.MapFileName = RawGames[i]->AsObject()->GetStringField("map_file_name");
			DeserializedGames.Push(Data);
		}
		return DeserializedGames;
	}
	return DeserializedGames;
}

Does anyone know how to fix this issue?

Did you compile with LiveCoding while editor is open ? When you do that, whatever you compile doesn’t really carry over to the next editor session. For any structural changes, I suggest always close editor before compiling, and reopen afterwards.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.