How do I remove a C++ class from my project code?

I just did that and now my level got wiped out as well… Good thing it was just a test level.

Don’t give up! The biggest issue with learning UE4 from a C++ background is realizing that when you compile there is essentially a new intermediate step as the Build tool runs through your project and processes all the files to create the intermediate code that you do not have to generate for stuff like reflection, and then it builds your code. It took me a good 3-4 months of bugging a lot of people and reading a lot of articles to get a grip on it. But it’s worth it…

o.O your test level should not have been saved in the intermediate folder… and clean doesn’t clean out your content folder. You have essentially deleted your editor and game when you do this, which means when you rebuild it it may take the editor a few minutes to asynchronously load up all the assets in the browser and rebuild textures and materials, so it may “appear” that your level is missing but it should be safely in your content folder… now if you deleted your content folder… I can’t help you.

Hi XenoEgger and pfjarschel,

This was an ability that we had considered implementing about a year ago, but it was deemed to be too risky to add the capability to the Editor.

Really feel like this should get on the road map at some point. Even locking this down to somewhere in the editor options disabled by default with several confirmation steps per class deletion. A good midpoint might be having official documentation for how to do this step. Thanks for helping us understand how to get unblocked! :slight_smile:

Where do I get the “generateProjectFiles.bat” from?

Hi crazydaze,

You will actually want to right-click on the .uproject file and select the “Generate Visual Studio project files” option.

What was the reasoning behind “too risky”? Why would it be risky to allow professional programmers to be able to delete their classes in a few steps as they would when working without an engine editor? I am curious as to what audience Epic is aiming to hand-hold when it comes to C++ programming with UE4.

Hi furinyx,

Unfortunately the process of deleting a code class from a project is not always as simple as deleting a couple files. The Editor would be able to find and remove the header file for the class since that information is available to the Editor. However, even though most class source files use the same name as the header file, this is not a requirement and the Editor may not be able to locate the source file for the class in order to remove it. In addition, class method definitions can technically be found in any file within the module that contains the class. That means the Editor would potentially have to remove lines of code from other files in the module.

Another concern is any remaining references to the class that is being deleted. References in a uasset file (such as a Blueprint) can be flagged by the Editor to let you know that they will need to be corrected. However, any code references to the class will not be found until a build is initiated after the class is deleted. Once a broken code reference looking for the deleted class is found in the build, the project is essentially broken until you manually correct any remaining broken code references.

While it may be theoretically possible to implement a feature allowing a code class to be deleted from the Editor, it would be a very large task to implement an automated system we would not be able to guarantee would work in all situations. The truly unfortunate side effect to this system would be that we would not be able to verify whether the code class was deleted successfully until after it was deleted. The first indication of a problem would likely be when the subsequent build fails. Depending on a user’s setup, this may not be something they could recover from.

1 Like

What is all this drama about? A notification every few days about activity on this question. I’m gonna delete this question

Looks like I can’t even delete it. Admins please lock/delete this question