(UE5) How to spawn blueprint actor with C++?

Thank you so much for your help!
But it still doesn’t work in my project…
Could you check my code…?

I am trying to spawn an actor with the Widget button

Widget File

void UEditorWidget::CreateNoteClicked()
{
	m_editorPlayer->SpawnNote();
}

Player File
h file

public:
	UPROPERTY(EditDefaultsOnly)
		TSubclassOf < AEditorNote> m_noteToCreate;

CPP

void AEditorPlayer::SpawnNote()
{
	GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Orange, FString("EditorPlayer Spawn Note!"));
	GetWorld()->SpawnActor<AEditorNote>(m_noteToCreate);
}

Also, I selected my bp file in the editor…

2 Likes