UE4/5 | 纯蓝图工程项目转为C++工程项目
一个纯蓝图工程打开的话会报错:
This project does not have any source code. You need to add C++ source files to the project from the Editor before you can generate project files.
要转化为C++工程只需要在根目录添加Source文件夹(空文件夹即可),然后就可以右键Generate Virtual Studio project files 生成.vs文件。
之后在Source文件夹中新建 三个文件 项目名##.Target.cs 文件
using UnrealBuildTool;
using System.Collections.Generic;
public class 项目名Target : TargetRules
{
public 项目名Target(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "项目名" } );
}
}
项目名##Editor.Target.cs 的文件
using UnrealBuildTool;
using System.Collections.Generic;
public class 项目名EditorTarget : TargetRules
{
public 项目名EditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "项目名" } );
}
}
- 一个项目名文件夹,文件夹中新建 项目名##
Build.cs 文件:
using UnrealBuildTool;
public class 项目名 : ModuleRules
{
public 项目名(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
bEnableUndefinedIdentifierWarnings = false;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore"});
PrivateDependencyModuleNames.AddRange(new string[] {});
}
}
然后重新编译生成项目
|