重命名UE4项目
Hi!
Thanks for your patience - I wanted to check with an engineer and also run through these steps for renaming a C++ project. There may be some additional steps needed depending on the original project setup and the version you are on, so please let us know if you encounter any issues following these steps (or if you need additional steps for Mac).
This example is for creating a copy of OldName called NewName. I'd recommend doing this as a duplication process if at all possible, in case there are issues during the rename.
-
Duplicate the
OldName
project folder. Rename the duplicate folder toNewName
. -
Open the
NewName
folder. -
Rename
OldName.uproject
toNewName.uproject
. -
Open
NewName.uproject
in a text editor, and replace all instances ofOldName
withNewName
. Save and close the file. -
If you have an
OldName.png
thumbnail, rename it toNewName.png
. -
Open the
Source
folder. -
Rename
OldName.Target.cs
toNewName.Target.cs
. -
Open
NewName.Target.cs
. Find all instances ofOldName
in this file withNewName
. There may be some partial word matches. Save and close the file. -
Repeat step 7 and 8 for
OldNameEditor.Target.cs
(renaming it toNewNameEditor.Target.cs
. -
Rename this
OldName
folder toNewName
as well. -
Open the
NewName
folder. -
Rename
OldName.Build.cs
toNewName.Build.cs
. -
Open
NewName.Build.cs
. Find all instances ofOldName
in this file withNewName
. Save and close the file. -
Go back to the main project folder, and right-click on the
NewName.uproject
file. Select Generate Visual Studio Project files. (If you don't have this option, runEngine/Binaries/Win64/UnrealVersionSelector-Win64-Shipping.exe
once). -
Open
NewName.sln
. -
Open
OldName.cpp
-
Change
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, OldName, "OldName" );
toIMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, NewName, "NewName" );
-
Open the
Config
folder, and check all the configuration files forOldName
references to change toNewName
. For example, changeGlobalDefaultGameMode=/Script/OldName.OldNameGameMode
toGlobalDefaultGameMode=/Script/NewName.OldNameGameMode
. -
Add the following to
DefaultEngine.ini
(under an existing or new[/Script/Engine.Engine]
header):+ActiveGameNameRedirects=(OldGameName="/Script/OldName", NewGameName="/Script/NewName")
-
If you have any
OLDNAME_API
in your project's header files, change those instances toNEWNAME_API
. -
Delete
Saved
andIntermediate
folders in your project directory. -
Compile, and your project should now open without errors.
Again, please let us know if any issues come up with these renaming steps. Thanks!