C++ UMaterialInstanceDynamic output function?

Hi, I want to have a MaterialInstance-TArray in my Gamemode together with a “GetMaterialArray()” function for other to use those materials.
In the MyGameMode.h I have:

TArray<UMaterialInstanceDynamic> MaterialListArray;
void MaterialList(TArray<UMaterialInstanceDynamic>& Materials);

and in the cpp I tried:

void MyGameMode::MaterialList(TArray<UMaterial>& Materials) 
{
	Materials.Empty();
	Materials.Append(MaterialListArray);
}

But I get the error message that it’s not allowed to get access to private members of UMaterial
I also tried Materials.Append(MaterialListArray.GetData()); but that isn’t working either. Unfortunately Google didn’t really help, so I’m trying my luck here - thanks for the help

Hello. I think you forgot the *

Try this:

.h:

TArray<UMaterialInstanceDynamic*> MaterialListArray;
void MaterialList(TArray<UMaterialInstanceDynamic*>& Materials);

.cpp:

void MyGameMode::MaterialList(TArray<UMaterialInstanceDynamic*>& Materials)
{
	Materials = MaterialListArray;
}

Found it out later the same day, you are absolutely right, thanks still for taking the time for the next one having that problem :smiley: