Hi ,
Thank you for providing the exact code to reproduce this issue.
I was able to reproduce the crash related to CanvasRenderTarget2D and have submitted a report for further investigation of that issue (UE-4570). However, I still have not been able to reproduce the crash using TextureRenderTarget2D. Using the code below, I was able to load the project normally.
// .h
UCLASS()
class TESTSOLUS_API AMyStaticMeshActor : public AStaticMeshActor
{
GENERATED_UCLASS_BODY()
UPROPERTY()
UTextureRenderTarget2D* RenderTex;
FCanvas* Canvas;
};
// .cpp
AMyStaticMeshActor::AMyStaticMeshActor(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
FVector2D Dimensions(512, 512);
RenderTex = CastChecked<UTextureRenderTarget2D>(StaticConstructObject(UTextureRenderTarget2D::StaticClass()));
RenderTex->AddToRoot();
RenderTex->ClearColor = FLinearColor(0, 0, 0, 1);
RenderTex->bNeedsTwoCopies = false;
RenderTex->bHDR = false;
RenderTex->InitCustomFormat(Dimensions.X, Dimensions.Y, EPixelFormat::PF_A16B16G16R16, true);
RenderTex->UpdateResourceImmediate();
Canvas = NULL;
//Canvas = new FCanvas((FTextureRenderTarget2DResource*)RenderTex->Resource, NULL, 0, 0, 0); // Works in 4.4.3, not in 4.5
Canvas = new FCanvas((FTextureRenderTarget2DResource*)RenderTex->Resource, NULL, GetWorld(), ERHIFeatureLevel::SM4);
Canvas->Clear(RenderTex->ClearColor);
}
Unless I am missing something, that should be identical to the code you provided to reproduce this crash. Do you see any differences between what you have in your project and what I have here?