Creating an Instanced Static Mesh without AddInstance()

I’m basically attempting to create an instanced static mesh instance in a more direct way than AddInstance(). This isn’t just because I’m trying to cause myself pain; it’s part of a bigger picture, but this is a minimum working example of my problem:


#include "Runtime/Engine/Private/InstancedStaticMesh.h"
#include "Runtime/Engine/Classes/Components/InstancedStaticMeshComponent.h"
#include "Runtime/Engine/Public/StaticMeshResources.h"
// Plus other things


// other things

// I make an UInstancedStaticMeshComponent* called ISMComp.

// Set up for the instanced data
FStaticMeshInstanceData* a = new FStaticMeshInstanceData(true, false);
// I'm only adding a single instance, but I will be adding more later
a->AllocateInstances(1, true); 

// Create the SM data, and add a single element (eventually I'll have this in a loop)
TArray<FInstancedStaticMeshInstanceData> smdata;
auto NewInstanceData = new(smdata) FInstancedStaticMeshInstanceData(Test); // Test is just an FMatrix with sample coordinates/rotations
ISMComp->PerInstanceSMData = smdata;

ISMComp->InitPerInstanceRenderData(false, a);
ISMComp->PerInstanceRenderData->UpdateFromPreallocatedData(ISMComp, *a, true);

ISMComp->PerInstanceRenderData->InitResource(); // Complation Error is due to this line


This seems to make sense to me, but when I compile I get the painful error: CreatorInstrance.cpp.obj :

error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl BeginInitResource(class FRenderResource *)" (__imp_?BeginInitResource@@YAXPEAVFRenderResource@@@Z) referenced in function "public: void __cdecl UCreatorInstrance::Spawn(void)" (?Spawn@UCreatorInstrance@@QEAAXXZ)

I’ve tried compiling line by line, and it’s due to the InitResource() call.

Thank you very much

Made some edits, a few of my variables were wrong. Problem still stands however.