getting a strange crash when compiling.
- I haven’t touched any code involving NewObject or ObjectInitializer at all today, yet I’ve only seen this problem today. Possibly an issue with 5.3.1?
- Without changing any code in between, it compiles just fine after the editor reopens.
Fatal error: [File:D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectThreadContext.cpp] [Line: 32] Tried to get the current ObjectInitializer, but none is set. Please use NewObject to construct new UObject-derived classes.
UnrealEditor_CoreUObject!FObjectInitializer::Get() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:4423]
UnrealEditor_Engine!UTexture::UTexture() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Texture.cpp:230]
UnrealEditor_Engine!UTextureRenderTarget2D::UTextureRenderTarget2D() [D:\build\++UE5\Sync\Engine\Intermediate\Build\Win64\UnrealEditor\Inc\Engine\UHT\TextureRenderTarget2D.gen.cpp:400]
UnrealEditor_Engine!UCanvasRenderTarget2D::UCanvasRenderTarget2D() [D:\build\++UE5\Sync\Engine\Intermediate\Build\Win64\UnrealEditor\Inc\Engine\UHT\CanvasRenderTarget2D.gen.cpp:410]
UnrealEditor_Experiments_patch_1!USpriteSheetCRT::__VTableCtorCaller() [D:\My Documents\Unreal Projects\Experiments\Source\Experiments\Portraits\SpriteSheetCRT.h:15]
UnrealEditor_CoreUObject!UClass::HotReloadPrivateStaticClass() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5931]
UnrealEditor_CoreUObject!GetPrivateStaticClassBody() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:6529]
UnrealEditor_Experiments_patch_1!USpriteSheetCRT::GetPrivateStaticClass() [D:\My Documents\Unreal Projects\Experiments\Intermediate\Build\Win64\UnrealEditor\Inc\Experiments\UHT\SpriteSheetCRT.gen.cpp:110]
UnrealEditor_CoreUObject!UClassRegisterAllCompiledInClasses() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:697]
UnrealEditor_CoreUObject!ProcessNewlyLoadedUObjects() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp:896]
UnrealEditor_LiveCoding!FLiveCodingModule::AttemptSyncLivePatching() [D:\build\++UE5\Sync\Engine\Source\Developer\Windows\LiveCoding\Private\LiveCodingModule.cpp:814]
UnrealEditor_LiveCoding!FLiveCodingModule::Tick() [D:\build\++UE5\Sync\Engine\Source\Developer\Windows\LiveCoding\Private\LiveCodingModule.cpp:767]
UnrealEditor_LiveCoding!TBaseRawMethodDelegateInstance<0,FLiveCodingModule,void __cdecl(void),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:534]
UnrealEditor!TMulticastDelegate<void __cdecl(void),FDefaultDelegateUserPolicy>::Broadcast() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:956]
UnrealEditor!FEngineLoop::Tick() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:6093]
UnrealEditor!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:188]
UnrealEditor!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:118]
UnrealEditor!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:258]
UnrealEditor!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:298]
UnrealEditor!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll
code for USpriteSheetCRT (public UCanvasRenderTarget2D), in the event it matters:
uint32 USpriteSheetCRT::CalcTextureMemorySizeEnum(ETextureMipCount Enum) const
{
//copied from UTextureRenderTarget2D, as Super or simply not overriding don't work
// Calculate size based on format. All mips are resident on render targets so we always return the same value.
EPixelFormat Format = GetFormat();
int32 BlockSizeX = GPixelFormats[Format].BlockSizeX;
int32 BlockSizeY = GPixelFormats[Format].BlockSizeY;
int32 BlockBytes = GPixelFormats[Format].BlockBytes;
int32 NumBlocksX = (SizeX + BlockSizeX - 1) / BlockSizeX;
int32 NumBlocksY = (SizeY + BlockSizeY - 1) / BlockSizeY;
int32 NumBytes = NumBlocksX * NumBlocksY * BlockBytes;
return NumBytes;
}
void USpriteSheetCRT::OnReceiveUpdate(class UCanvas* Canvas, int32 Width, int32 Height)
{
UE_LOG(LogTemp, Log, TEXT("OnReceiveUpdate"));
UMaterialInstanceDynamic* bodyDMI = UKismetMaterialLibrary::CreateDynamicMaterialInstance(this, BodyMaterial);
bodyDMI->SetTextureParameterValue("Upper", UpperBody);
bodyDMI->SetTextureParameterValue("Lower", LowerBody);
FLinearColor skinHSL = UColorQuartetBFL::RandomSkinHSL();
bodyDMI->SetVectorParameterValue("Skin", UColorQuartetBFL::HSLtoRGB(skinHSL));
Canvas->K2_DrawMaterial(bodyDMI, FVector2D(0,0), FVector2D(Width, Height), FVector2D(0,0));
int coords[6][2] = { {118, 109}, {133, 382}, {136, 710}, {136, 1010}, {120, 1270}, {140.5, 1663.5} };
FVector2D scale = FVector2D(6,6);
UMaterialInstanceDynamic* headDMIIdle = UKismetMaterialLibrary::CreateDynamicMaterialInstance(this, HeadMaterial);
headDMIIdle->SetTextureParameterValue("Eyes", Eyes);
headDMIIdle->SetTextureParameterValue("Mouth", Mouth);
headDMIIdle->SetTextureParameterValue("Hair", Hair);
Canvas->K2_DrawMaterial(headDMIIdle, FVector2D(coords[0][0] - 125, coords[0][1] - 150), FVector2D(Width, Height), FVector2D::Zero(), scale);
Canvas->K2_DrawMaterial(headDMIIdle, FVector2D(coords[1][0] - 125, coords[1][1] - 150), FVector2D(Width, Height), FVector2D::Zero(), scale);
Canvas->K2_DrawMaterial(headDMIIdle, FVector2D(coords[5][0] - 125, coords[5][1] - 150), FVector2D(Width, Height), FVector2D::Zero(), scale, 15, FVector2D(125/1500.0f, 150/1800.0f));
UMaterialInstanceDynamic* headDMIAttack = UKismetMaterialLibrary::CreateDynamicMaterialInstance(this, HeadMaterial);
headDMIAttack->SetTextureParameterValue("Eyes", Eyes);
headDMIAttack->SetScalarParameterValue("EyeIndex", 1);
headDMIAttack->SetTextureParameterValue("Mouth", Mouth);
headDMIAttack->SetScalarParameterValue("MouthIndex", 2);
headDMIAttack->SetTextureParameterValue("Hair", Hair);
Canvas->K2_DrawMaterial(headDMIAttack, FVector2D(coords[2][0] - 125, coords[2][1] - 150), FVector2D(Width, Height), FVector2D::Zero(), scale);
Canvas->K2_DrawMaterial(headDMIAttack, FVector2D(coords[3][0] - 125, coords[3][1] - 150), FVector2D(Width, Height), FVector2D::Zero(), scale);
UMaterialInstanceDynamic* headDMIBack = UKismetMaterialLibrary::CreateDynamicMaterialInstance(this, HeadMaterial);
headDMIBack->SetTextureParameterValue("Eyes", Eyes);
headDMIBack->SetTextureParameterValue("Mouth", Mouth);
headDMIBack->SetTextureParameterValue("Hair", Hair);
headDMIBack->SetScalarParameterValue("Facing", 2);
Canvas->K2_DrawMaterial(headDMIBack, FVector2D(642.5 - 125, 1639.5 - 150), FVector2D(Width, Height), FVector2D::Zero(), scale, 15, FVector2D(125 / 1500.0f, 150 / 1800.0f));
}
//couldn't find a better place to put this one thing, so it gets to be a function for right now
//this is all just experimental for right now
void USpriteSheetCRT::Setup()
{
OnCanvasRenderTargetUpdate.AddDynamic(this, &USpriteSheetCRT::OnReceiveUpdate);
}
(nothing special in SpriteSheetCRT.h, just declarations of variables and the above functions.)