EditAnywhere does not work with staticmesh?

I declared the mesh in the header:

//the mesh
UPROPERTY(EditAnywhere,BlueprintReadWrite, Category = "Mesh")
UStaticMeshComponent* mesh;

And create the mesh in the source file:

//create mesh component
  mesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("MainMesh"));
  RootComponent = mesh;

But when I go back to ue4 editor,create a BP class based on the class above,open the BP editor,I found the staticmesh component like this in the picture:

Anyone can help to work it out?I just want to create a staticmesh component in a c++ class,and dirve a BP class form it,then I can choose mesh and material form the editor.

Hello wenbo226226,

If you go to the same panel that you have shown in the picture and click the Arrow on the left of “Mesh”, it should give you a list of more fields about the Mesh’s settings. This should allow you to change the Static Mesh under the ‘Static Mesh’ category that appears.

Hope this helps!

Thanks!It works!

Mine has no arrow in the editor just has a note saying “Native components are editably when declaired as a UProperty”

UPROPERTY(EditAnywhere)
UStaticMeshComponent * SM_MyMesh;

any ideas?

Never mind. Had to delete it form the scene and add it again after the compile.