How to edit an existing C++ class

Sorry if this is a stupid question, but how do I edit C++ classes?

Specifically what I want to do is edit the ShooterAIController class in the example ShooterGame (or a clone of it to be exact). If I right click ShooterAIController in the content browser, I see Create derived class and Edit options.

Clicking Edit takes me to the Visual Studio editor, but only the .h file is opened. I can see no way to access the .cpp file.

Clicking Create derived class I get an error: Failed to add class MyShooterAIController. Failed to automatically hot reload the ‘ShooterGame’ module. However, that does do something, as trying to do the same reports that the class already exists. I just cannot see it anywhere.

Although I have experience of OO languages, I am not at all familiar with C++ or the UE, so please keep replies simple!

I just created the Shooter Game example. Tried to modify the ShooterAIController class and I’m getting the same problem that you are encountering.

First thing, if you go in your project folder, do you have the .sln file?

I didn’t. So you need to create it. Just go in your project folder and right-click on your .uproject file and click on Generate Visual Studio project files.

From there, double click on the .sln file in order to compile the project. Once VS is open, it will be parsing the files, wait until it’s finish (it can take up to 10 15 minutes depending on your system!). From there, on the root directory of the project (mine is called: Solution’ShooterGame’ (2 projects)), right click and select build solution.

Once it is finished, go back to the editor and try it again and now you should have access to all of the files.

Now once that is done, right-click again on your file and click on edit. It will open up in VS. It will be the header file. from there, you can pick a function, right click and select Go to Definition and that will open up the .CPP file.

and voilà, you have access to it.

But, yes I have to agree, it is strange that the CPP files aren’t showing up.

Hope this helps and happy game deving :wink:

1 Like

Thanks, very comprehensive. I was not going to guess that!

FWIW, I did make a change for 4.8 so that opening a class via the Content Browser will now try and open the corresponding .cpp file as well as the .h file.