Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Rename C++ File


Just a quick question. Let's say I have a file called MyClass.ccp and MyClass.h in the VS Solution. If I rename those files, Unreal Engine auto regenerate the project and I lose my changes...

what is the workflow to rename class files?

Product Version: Not Selected
more ▼

asked Oct 01 '14 at 07:52 PM in C++ Programming

avatar image

85 12 20 24

avatar image TimGS Oct 01 '14 at 08:40 PM

What do you mean you lose your changes? And what is auto-regenerate? Projects are generating when you change Engine version or choose Regenerate projects. Both operations are manual. Also, projects generator doesn't touch source files. It just scans your Source folder and organize VS project files and solution file.

avatar image Anubis Oct 01 '14 at 08:47 PM

For example:

  • I add code, lets say AItem.

  • I rename then in VS the code to AItem2 and all the includes and references

After that, Unreal Engine cannot compile anymore with an error of AItem not found.

Same happens if I try to remove AItem.cpp and AItem.h

avatar image TimGS Oct 01 '14 at 08:58 PM

You filename should match your UClass name. So if your rename your UClass from AItem to AItem2 you should rename your header and source files to Item2.h and Item2.cpp.

Here's documentation for unreal code standards: https://docs.unrealengine.com/latest/INT/Programming/Development/CodingStandard/index.html

avatar image mikepurvis Oct 01 '14 at 08:51 PM

Are you renaming through Visual Studio?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

If you want rename .cpp/.h files in Visual Studio, just do it, they will become renamed on disk, not only in project.

If you want to remove files from Visual Studio project, you must do it outside of Visual Studio, manually, using Windows Explorer. Because if you remove files only in Visual Studio, they will not be deleted from disk and GenerateProjectFiles.bat will include that files to project again and again.

If you want add new files to Visual Studio project, best way to do this is to open your project in Unreal Editor and use Edit->AddCodeToProject.

more ▼

answered Oct 01 '14 at 11:41 PM

avatar image

1.1k 119 143 373

avatar image Moss Oct 02 '14 at 07:10 AM

Apart from what newbprofi said if you rename those files that contain UObjects (those that have a corresponding myclass.generated.h file) you have to re-generate the project files.

avatar image Anubis Oct 02 '14 at 06:44 PM

Ok Great, I needed to know all this workflow of: rename/ delete file, generate again the sln, compile it... and then reopen UE.


(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question