Access to TArray via a user programmed blueprint function in C++


i want to open a .txt-Map file with a function and this function should resize and fill the array which i want to give in as blueprint.
But for some reason if i do Array.Empty() nothing happen with the Array.

Does someone know how to do this?

My Blueprint looks like this:

And the Code:

bool UFile::LoadIntegerArrayFromFile(FString LoadDirectory, FString FileName, TArray<int32> Array, int32 &Width, int32 &Height, int32 &ArraySize)

	FString Text;

	int32 TextLines;
	TArray <FString> TextLine;

	//Dir Exists?
	if (!FPlatformFileManager::Get().GetPlatformFile().DirectoryExists(*LoadDirectory))
		return false;

	//get complete file path
	LoadDirectory += "\\" + FileName;

	//get data
	if (FFileHelper::LoadFileToString(Text, *LoadDirectory))
		TextLines = Text.ParseIntoArrayLines(&TextLine);

		Width = FCString::Atoi(*TextLine[0]);
		Height = FCString::Atoi(*TextLine[1]);
		ArraySize = Width*Height - 1;
		Array.Empty(); // <-- Nothing happen!

		for (int32 i = 2; i < TextLines; i++)
			// fill Array



		return true;

	return false;


Tanks Greetings

You’re passing in the array as a value, so it makes a copy of it, and you can manipulate it in that function, but there is no mechanism for it to be put back in to your array.

In general we don’t do a lot of passing in arrays/structs as reference and modifying them in place.

In your case I think you are best off having a output parameter of the Array that will give you another output parameter that is your array.