Code compiles in Visual Studio, but the changes are not reflected in the editor

I am having a lot of trouble trying to figure out what my problem is. My code compiles successfully within Visual Studio, but the changes that I make to my code are not appearing in-editor. For example, I changed some of my variables from the uproperty VisibleAnywhere to EditAnywhere, but in the editor they are still showing up as greyed-out boxes that I cannot change (I had heard hot reload is finicky with header files). I also added an OnClicked function to a skeletal mesh, but this function is not being called when I do click on the skeletal mesh, and I have a feeling it is due to the changes in code not being reflected in the editor.
I have tried deleting the visual studio project file, the intermediate folder, the binary folder. I tried opening visual studio from the editor after generating project files, but that didn’t work either. I have even cloned the repository from github hoping that it would fix the issue, but it did not. I am not sure if this is a hot reload issue, but any help would be greatly appreciated.

edit: So on second look at my code, I determined why the editor was not updating the variables I changed, and it was simply because I declared an instance of the struct containing those variables with VisibleAnywhere, so of course they would not be editable. But, I am still having difficulty with the clicked events. The definition of the function in my .h file is this:

	UFUNCTION()
	void OnClicked(UPrimitiveComponent* ClickedComponent, FKey ButtonPressed);

And in the constructor in the .cpp file,

UnitSkeletalMesh->OnClicked.AddDynamic(this, &AUnitBase::OnClicked);

And the actual function:

void AUnitBase::OnClicked(UPrimitiveComponent* ClickedComponent, FKey ButtonPressed)
{
	UE_LOG(LogTemp, Warning, TEXT("In OnClicked."));
}

Any help with this problem is very welcome.

This may seem like a stupid question, but did you press the compile button in UE4? I used to have the same problem when I would compile in VS17 instead of with the in-editor button.

Would be helpful to see code.

Yeah, I tried the compile button in the editor as well, but that didn’t update the code for some reason.

Relating to the skeletal meshes problem. Does your mesh have collision enabled?

See This Thread

Wow, so that was my problem, not visual studio like I thought. Thanks a lot for that reference and your help.

Solution: Make sure you have collision enabled on your mesh for onClick events otherwise your onClick event will not fire as your mouse click will not see your mesh :slight_smile: