UFUNCTION cause missing link error

Hello everyone,

I’m trying to implement a function (in a UActorComponent) that from a string returns an array of textures.

Header:

UFUNCTION(BlueprintCallable, Category = "CameraDirector")
TArray<UTexture> GetFrames(FName shotSize);

implementation:

TArray<UTexture> GetFrames(FName shotSize)
{
	TArray<UTexture> frames;
	//TArray<FStringAssetReference>& shotSizeArray = cameraAngles[shotSize];
	//FStreamableManager& Streamable = UDMLSingleton::Get().AssetLoader;

	//for (auto& assetReference : shotSizeArray)
	//{
	//	//frames.Add(Cast<UTexture> (Streamable.SynchronousLoad(assetReference)));
	//}
	
	return frames;
}

As you may see the the function is almost all commented, because I immeditely got a compile error and I wanted to have the bare minimum to avoid confusion.

Th error:

MyProjectPath/Source/unreal_myproject/CmpntCameraDirector.h(25) : Missing '*' in Expected a pointer type
Error : Failed to generate code for unreal_myprojectEditor - error code: OtherCompilationError (5)

I searched the error here in the hub, but I found answers that contraddict each other. Here and here is said that the use of pointers is forbidden. Here instead is accepted an answer that propose as solution to use a pointer!

I decided to go for the second solution (I was not using pointers in the first place) and I don’t get that error anymore, but I got a new one.

New method signature:

UFUNCTION(BlueprintCallable, Category = "CameraDirector")
TArray<UTexture*> GetFrames(FName shotSize);

New error:

CmpntCameraDirector.cpp.obj : error LNK2019: unresolved external symbol "public: class TArray<class UTexture *,class FDefaultAllocator> __cdecl UCmpntCameraDirector::GetFrames(class FName)" (?GetFrames@UCmpntCameraDirector@@QEAA?AV?$TArray@PEAVUTexture@@VFDefaultAllocator@@@@VFName@@@Z) referenced in function "public: void __cdecl UCmpntCameraDirector::execGetFrames(struct FFrame &,void * const)" (?execGetFrames@UCmpntCameraDirector@@QEAAXAEAUFFrame@@QEAX@Z)
unreal_myproject.generated.cpp.obj : error LNK2001: unresolved external symbol "public: class TArray<class UTexture *,class FDefaultAllocator> __cdecl UCmpntCameraDirector::GetFrames(class FName)" (?GetFrames@UCmpntCameraDirector@@QEAA?AV?$TArray@PEAVUTexture@@VFDefaultAllocator@@@@VFName@@@Z)
MyProjectPath\Binaries\Win64\UE4Editor-unreal_dontmakelove-494.dll : fatal error LNK1120: 1 unresolved externals

Apparently the problem is connected to TArray, because for test purpose I changed the function to return an array of FString and I got the same error.

It’s important to notice that if I don’t use UFUNCTION I don’t get any error. I’m new to C++ (even though I’m learning it, and I know Java and C#) so probably I’m missing something here, but I really need to have this function accessible from blueprint.

Any suggestion?

Your implementation is missing class name. It should be:

TArray<UTexture*> YourActorComponentName::GetFrames(FName shotSize)
{
    // Do stuff...
}

This is really embarassing, probably I need an eye doctor XD
Thanks a lot!