How do I remove Code From Project?

Earlier I asked about changing a classes name, it was suggested that it would be easier to make a new class instead. I asked because I like to keep my projects clean, and refactoring is a large part of that. So, if one were refactoring, the need might arise to remove some classes/files from the project. How is this done?

Let me be more clear. The issue I was having is that once I created a class I was no longer able to create new classes with the same name, even if I deleted the class from my project. If you can only use class-names once, In a large project it’s not hard to imagine someone wanting to use a class-name that belongs to a class that’s been deleted.


I am not sure I understand the question,

if you are compiling in VS, and you delete the .cpp and .h from your Source folder,

and then recompile

Doesn’t that work for you?


Yes, but lets say you had originally made an actor called “AssistantManager”, but later on for w/e reason, decided you wanted to use the AssistantManager name to describe a GameManager class.

“Once you create a project a lot of internal linking occurs based on the name you choose for the project.” Change File/Class Names - Programming & Scripting - Epic Developer Community Forums

Would you still have to go into the config and ini files and reconfigure all that internal linking?

The real issue is only with renaming your entire project,

renaming individual classes, or deleting them, should work quite fine!

I did a lot of that today actually, in new UE4

it’s perfectly fine :slight_smile:

Not sure if I am understanding situation perfectly

but if you rename or delete .cpp and .h files you’re fine

except if you make blueprints and reparent them to a C++ class

then you should make a NEW class that is renamed version

reparent the BP to the NEW version

then delete the old one

its still quite doable

#You Are Going to Be Fine

You are gonna be okay, just remember the one bit about blueprints that are reparented

and dont delete classes till you are ready to let go of the BP, or transfer it to a new parent first

Hmm okay. I think there was some misunderstanding in our original discussion. I’m going update that original question when I can do so accurately, as the sources/issue I had at the time has been deleted.

Thanks for the timely answers.

Strange. Today I made a project and added a few test files in the editor. Then, I deleted them from the solution and recompiled. But, they were still available to be placed when I ran the editor again.

It’s an old question, but I couldn’t find an answer.
I deleted a class in visual studio by deleting the .h and .cpp files, then recompiled. Then in the editor I also recompiled, but then I tried “Refresh Visual Studio Project” and it brought the files back again.

What is the correct way to delete them?

You need to actually delete the files from the folders using Windows Explorer by hitting delete or throwing them in the Recycle Bin (or just move them to your desktop or wherever). When you delete them in Visual Studio, you’re probably only deleting their existence in the project, and not the files on the disk. So when you recreate the project files, the Unreal build tool sees the files still in the directory, and puts their entries back into the project.

They would be in the address similar to: MyDocuments/Unreal Projects/ Your Project / Source / Your Project / Public (and also Private)

Thank you, this is what happened to me

It’s been a while since I followed up on this, but things are working as people are saying. For example.

I added an Actor called MyActor, compiled, rebuilt, made a blueprint out of the MyActor class, deleted it, closed UE4, deleted MyActor.h/cpp from both the project and the filesystem, rebuilt, and tried to make a new blueprint based off MyActor and as one would expect, it was gone.

Then I tried to do what I did that spurred me to make this thread in the first place. I tried to add a new MyActor class via the Editor and I no longer had problems. I don’t know if this was just a previous version issue or an error on my part, but I suspect it was that I was only deleting the files from the solution, not the source folder.

This. This was my issue too. Looking back Rama was trying to tell me this from the start.