Can't add code that inherits from classes other than Actor

I have come across this issue using UE4.7.4(binary build) on a Win8.1 x64 using VS2013 Ultimate. When trying to add C++ code through the appropriate menu entry in the editor, and selecting the WidgetBlueprint as parent class an error message pops up saying:

"Failed to add class WhateverYourClassIsNamed. Failed to automatically hot reload the ‘YourProjectName’ module."

After pressing “OK” on the popup, a red warning appears on the class creation window saying:

"The name WhateverYourClassIsNamed is already used by another class."

The thing is, the corresponding .h and .cpp DO get created, however the hot reload fails. What’s more, whenever the newly created class needs to include a header (i.e. all classes except the ones created through the “None” category, right?) the compiler fails to locate the file, no matter how much I fiddle around with the include folders/paths. I’ve checked through the file explorer and the required headers do exist precisely in the folder pointed at by the include path. I’ve also tried to clear the Temp folder as per this. Regenerating the project files doesn’t help either.

I’d like to know whether there is any known solution for this and/or if this is a known bug. It would be a pity having to downgrade to 4.6 again, since I love the C++ improvements of 4.7 :slight_smile:

Thanks!

I do not know what causes that but I’ve seen it when I first started (about a week ago), and a couple of days after that. Oddly I haven’t seen it since, but yeah, when it pops up the only solution I found is to close the project and start it again (although I haven’t tried “Recompile” button yet - maybe that would work). Anyone got any ideas what this is ?

For the meantime, you can just regenerate the project files by right-clicking and it’ll pick up the created files.

One thing to know though, If you’re using source control, this can sometimes be caused by not checking out the .SLN files and the .VCProj files in the intermediate directory. Perforce sets all of the files to read-only until you check them out, and if any of the source files are read-only, Unreal won’t be able to modify or reload them.

I don’t know for certain, but Windows 8.1 might have introduced some new (pointless) security feature that makes the files read-only. Try checking that!

Sadly, for some reason this doesn’t work for me :frowning: No matter the combination I try, I always end up having the Red Squiggly Lines of Doom under the required include lines (the one for the .generated.h too).
Thanks for the heads up regarding source control. I’m currently not using any; I still checked the permissions both in the install folder and the project folder, but to no avail.
How must I go about filing a bug report correctly?

Are you using nested subdirectories that go deeper than 1 subfolder? i.e.: MyProject/Source/MyProject/Public/Subdirectory1/Subdirectory2/

If you are then that would be why. I’m an organizational freak and like using subdirectories to organize things but the editor doesn’t like it when you go more than 1 subdirectory deep (i.e. deeper than Subdirectory1). The code still adds to the solution fine but the editor can’t recompile it for hot-reload even with explicitly adding public and private include paths to the build file for any of those subdirectories that have headers. When this happens, I have to close the editor down and run the editor from a debug in visual studio. After that it’ll recognize my new code assets no matter how deep they are.

Is that the issue for you as well?

edit: forgot to mention, sometimes (but not always) I’ll need to delete the AssetRegistryCache.bin from the intermediate folder before running a debug to fire up the editor from visual studio. Wierd, because it’s not consistent and I haven’t been able to find a common element that causes it.

No, I’m not. In fact, there’s something that bothers me. It used to be when creating a C++ project, that the Public and Private folders got created automatically. Now (4.7) they don’t. Is anyone else encountering this as well?

Regarding my problem, I tried everything you say and nothing works. In my case, even if I close the editor, I can’t start the debug instance from VS because I get the “Couldn’t find header files” compile error for the newly added class.
I even went mad and performed a clean installation (after deleting the stuff in AppData and EVERYWHERE). No dice. I guess I’ll be waiting until 4.8 comes out and (hopefully) solves this problem.

The public and private folders don’t get auto generated anymore on project creations because it’s not really “required” for a game project (its more intended for modules/plugins to control what gets exposed to outside consumers of the module and nothing should really be using your game as a module).

Well, at least that’s something off of my mind. Thanks :slight_smile:

After reinstalling a lot of things, it seems some of the issues have disappeared (or I can’t remember testing the same before). I now only get the issue when trying to add code the project that inherits from WidgetBlueprint. Is this a known bug?

The Public/Private folders will be generated if you create the class insides a ‘Classes’ folder. Selecting the appropriate public/private setting in the dialog box will then place it in a Pub/Priv directory.

I still use it just because it keeps things organised. I don’t think there’s really much of a functional reason to do it though.

Thanks for the additional info.