Hey, so I am experimenting with setting a Texture Paramter inside a C++ class, but it crashes every time. My C++ source file inside the constructor:
static ConstructorHelpers::FObjectFinder<UStaticMesh> meshFinder(TEXT("StaticMesh'/Engine/EditorMeshes/EditorCube.EditorCube'"));
static ConstructorHelpers::FObjectFinder<UMaterial> materialFinder(TEXT("Material'/Game/Voxel/Materials/M_QR.M_QR'"));
static ConstructorHelpers::FObjectFinder<UTexture> textureFinder(TEXT("Texture'/Engine/EngineMaterials/T_Default_Material_Grid_M.T_Default_Material_Grid_M'"));
mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
UMaterial* material = materialFinder.Object;
UMaterialInstanceDynamic* minst = (UMaterialInstanceDynamic*)material;
UTexture* texture = textureFinder.Object;
minst->SetTextureParameterValue(FName(TEXT("QRTexture")), texture);
if (meshFinder.Object)
mesh->SetStaticMesh(meshFinder.Object);
mesh->SetMaterial(0, minst);
mesh->SetWorldScale3D(FVector(0.1, 1, 1));
mesh->bVisible = true;
RootComponent = mesh;
The paramteter is just an TextureSampleParameter2D, and I get this crash message when I compile and after that everytime I open the editor:
MachineId:AD538CEE405F8A26A01B3B910D50B2A2
EpicAccountId:d0fb234b758f4f36a97f7bdbbe031216
Access violation - code c0000005 (first/second chance not available)
""
UE4Editor_Engine!FMaterialRenderProxy::InvalidateUniformExpressionCache() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\materials\materialshared.cpp:1652]
UE4Editor_Engine!FMaterialInstanceResource::RenderThread_UpdateParameter<UTexture const * __ptr64>() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\materials\materialinstancesupport.h:118]
UE4Editor_Engine!EURCMacro_SetMIParameterValue<FTextureParameterValue>::DoTask() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\engine\private\materials\materialinstance.cpp:322]
UE4Editor_Engine!TGraphTask<EURCMacro_SetMIParameterValue<FTextureParameterValue> >::ExecuteTask() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\core\public\async askgraphinterfaces.h:779]
UE4Editor_Core!FTaskThread::ProcessTasks() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\core\private\async askgraph.cpp:539]
UE4Editor_Core!FTaskThread::ProcessTasksUntilQuit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\core\private\async askgraph.cpp:340]
UE4Editor_RenderCore!RenderingThreadMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\rendercore\private\renderingthread.cpp:310]
UE4Editor_RenderCore!FRenderingThread::Run() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\rendercore\private\renderingthread.cpp:411]
UE4Editor_Core!FRunnableThreadWin::Run() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.9\engine\source\runtime\core\private\windows\windowsrunnablethread.cpp:74]
Any suggetions?