Download

Errors appearing while using a UMaterialParameterCollection with ConstructorHelpers::FObjectFinder

I am currently attempting to make a UMG Widget in C++ that uses a Material Parameter Collection. The Collection has already been generated by creating it through the Content Browser and I am trying to find it’s file location through code by using ConstructorHelpers::FObjectFinder.

In searching for an answer to the problem online, this has been the solution format that has worked for other users.

My Current Implementation:


static ConstructorHelpers::FObjectFinder<UMaterialParameterCollection> MPCFind( TEXT ( "MaterialParameterCollection'/Game/ThirdPersonCPP/Minimap_Data'" ) );

I have already included ConstructorHelpers.h in the file so I know this is not the issue.

When I compile my code through the editor, using the above method of finding the MaterialParameterCollection, this is what my Debug Log displays:



C:\P4V\GamerCamps\Pro2017\Mod3\Work\Unreal\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h(109) : error C2664: 'void ConstructorHelpers::ValidateObject(UObject *,const FString &,const TCHAR *)': cannot convert argument 1 from 'UMaterialParameterCollection *' to 'UObject *'

C:\P4V\GamerCamps\Pro2017\Mod3\Work\Unreal\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h(109) : note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

C:\P4V\GamerCamps\Pro2017\Mod3\Work\Unreal\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h(102) : note: while compiling class template member function 'ConstructorHelpers::FObjectFinder<UMaterialParameterCollection>::FObjectFinder(const TCHAR *)'

V:\Unreal Projects\Minimap_Test\Source\Minimap_Test\Minimap_Widget.cpp(73) : note: see reference to function template instantiation 'ConstructorHelpers::FObjectFinder<UMaterialParameterCollection>::FObjectFinder(const TCHAR *)' being compiled

V:\Unreal Projects\Minimap_Test\Source\Minimap_Test\Minimap_Widget.cpp(73) : note: see reference to class template instantiation 'ConstructorHelpers::FObjectFinder<UMaterialParameterCollection>' being compiled


My assumption is that the Parameter Collection is not considered a UObject in the game and that this is why it doesn’t work but I’m not sure how else I would go about referencing the file location.

Thanks

FWIW: This is solved by including the header:
#include “Materials/MaterialParameterCollection.h”