Can't View C++ Classes

I originally planned on building my project without any code, but it seems that what I want to to do now can’t be done without it. So I’m trying to get VS2019 integrated with my project, and I’m running into an issue.

I can right click in the content browser and create a new C++ class. When I do so, it appears both in my source control and in my actual File Explorer. When I click a C++ class in UE4 - like just clicking “Character” after making a child of it - it’ll open the proper files in Visual Studio. Far as I can tell, UE4 and Visual Studio can see each other completely.

But I can’t see the files in UE4. I’ve got the “View Options” set for me to see the C++ classes, and I know I’m supposed to click the folder icon next to “Content”, but I still can’t see it. I also can’t create children of any of my C++ classes.

I’m not getting any errors in UE4 or VS to indicate something might be wrong, I just can’t see it. I don’t even know what files I could provide here to show what’s up. Can anyone tell me what I’m doing wrong?

So you’ve got Visual Studio installed. Great! I’m gonna start from there.

First steps

After you’ve got VS, you should find your project’s .uproject file, right click, and hit Generate Visual Studio Project Files. After that you’ll see that a .sln file was created in the same folder. This is you project’s “solution”. I recommend that you open this up, and let it parse all the unreal and project source codes. This will take a while, you’ll see what file is being parsed at the bottom of VS. When it says “Ready”, it means that it is done. Now you can either press F5 in VS to start the engine with VS attached (very good for debugging) or you can just open your project like you used to (from Epic Launcher, or by clicking on the .uproject file).

Creating a new C++ class

In your project nothing has really changed for now. So let’s say you want to create a new C++ class. In Unreal, at the top you’ll see File → New C++ class. Pick a parent class. After that you’ll see a window where you can decide the name, and where to put the file. Your project’s source code (the C++ files) will be outside of your project’s content folder. By default, the path will be correct so you don’t really have to change anything there. We usually split the project source code into “Public” and “Private” folders. C++ .h files go to public, C++ .cpp files go to the private folder. Unreal will automatically do this for you if you click the “Public” button on the right. (You may have to click “Private” first and then “Public”). Next step is to click on the green Create Class button. Unreal will start compiling. If you see an error message pop up, don’t worry! It happens a lot. Additionally, If you started the engine through VS, it will ask you if you want to reload the solution as well. You can hit “Yes to all” after you’ve closed the engine.

Solving initial errors

“So what to do if you got an error in Unreal when you created the class?”
Just close the engine, and press F5 again in VS.

"I pressed F5 but I get a compile error! I haven’t even coded anything yet!"
Usually this happens when you didn’t put the C++ file in the project’s root source folder. If this is the case, all you have to do is update the includes in the .cpp files. Let’s say you created MyCharacter class in Source/MyProjectName/Public/MyTestFolder/ so the default include path will be wrong.

// MyCharacter.cpp

// this is the default include path
#include MyCharacter.h

// this is the fixed include path
#include MyTestFolder/MyCharacter.h

“I created C++ classes already that I don’t need, how to delete them?”
Go to your project’s source folder, and delete the .h and .cpp files you don’t need. After that, find your .uproject file, right click, and hit Generate Visual Studio Project Files.

A bit of an overkill post, but I had a lot of issues with C++ project when I was starting out, so hopefully this clears some things up for you. Cheers!

I say in the post, I can already create new C++ classes and I’m not getting any errors in VS or in UE4. The issue is that after I create the classes, I’m unable to view them through UE4 (even with the “view C++ classes” active and looking beside the “content” folder).

I backed up my project and then built a new one as a C++ project rather than BP project. Lost a bit of progress, but this seems like the easiest and fastest way to solve whatever magical problem I created.