FMeshBatch was not properly setup

I derive a custom MeshComponent based on UMeshComponent, and draw the object into the scene by implementing FPrimitiveSceneProxy::DrawStaticElements. The code is as follows:
void FCustomMeshProxy::DrawStaticElements( FStaticPrimitiveDrawInterface* PDI)
const int IndexCount = IndexBuffer32.Indices.Num();
if( VertexBuffer.PositionVertexBuffer.GetNumVertices()> 0 && IndexCount> 0)
const float ScreenSize = 1.0f;

FMeshBatch MeshBatch;
MakeMeshBatch( MeshBatch, nullptr);
PDI->DrawMesh( MeshBatch, ScreenSize );

When PDI->DrawMesh( MeshBatch, ScreenSize );is called, a breakpoint is triggered,like this:

bool FMeshBatch::Validate(const FPrimitiveSceneProxy* PrimitiveSceneProxy, ERHIFeatureLevel::Type FeatureLevel) const

Output prompt:
Ensure condition failed: false [File:E:/UEProjects/UnrealEngine/Engine/Source/Runtime/Engine/Private/SceneManagement.cpp] [Line: 1133]
FMeshBatch was not properly setup. FMeshBatch was assigned a PrimitiveUniformBuffer even though the vertex factory fetches primitive shader data through the GPUScene buffer. The assigned PrimitiveUniformBuffer cannot be respected. Use PrimitiveUniformBufferResource instead for dynamic primitive data, or leave both null to get FPrimitiveSceneProxy->UniformBuffer.

In the editor mode, if the components in the scene are not selected, they cannot be drawn. After they are selected, they can be drawn. Please help me to point out what caused this problem?