如何更改子文件夹的#include默认文件路径
上下文:
我在UE4.23中遵循教程,在某一时刻,我们在source/projectName/
文件中创建子文件。然后,在.cpp/.h文件内部,我们只是写了#include“ subfolder/file.h”
,并被识别。但是,当我自己的项目练习时(在UE4.26中)时,我必须这样做:#include” ../ subfolder/file.h“”
从子文件中上升,告诉我,包括路径在文件夹内部的默认值。
这会导致令人讨厌的问题,在这种情况下,虚幻的问题会创建一个类,并假设我们在上部文件夹中启动了路径,从而导致每个新类引起编译错误包括。
问题:
如何更改默认值包含子文件夹文件的路径以从主文件夹启动?
所需结果的示例:将默认路径设置为“ ../ project/source/projectname/“
//thisclass.cpp file inside of "Source/ProjectName/Test/thisclass.cpp"
/* "Source/ProjectName/Framework/" */
#include "Framework/GameState.h"
/* "Source/ProjectName/Player/" */
#include "Player/CharacterController.h"
//Must enter sub-folders as well, even though it's in the same subfolder
#include "Test/thisclass.h"
副注:
- 我尝试使用Google解决方案的尝试不断显示用于更改项目位置的结果,而不是更改目录或包括路径。
- 我很确定这是一个视觉工作室问题,但是我正在使用虚幻的工作室,所以我都标记了这两个。
Context:
I was following a tutorial in UE4.23 and at one point, we create sub-files in the Source/ProjectName/
file. Then, inside of the .cpp/.h files, we simply wrote #include "Subfolder/File.h"
and it was recognized. However, when working on my own project to practice (in UE4.26), I have to do this: #include "../Subfolder/File.h"
to go up from the subfile, which tells me the include path is defaulting inside of the folder the file is in.
This causes annoying issues where Unreal will create a class and assume we start our path in the upper folder, causing a compile error with every new class until I manually change the include.
Question:
How do I change the default include path of sub-folder files to start from the main folder?
Example of desired result: Setting default path to "../Project/Source/ProjectName/"
//thisclass.cpp file inside of "Source/ProjectName/Test/thisclass.cpp"
/* "Source/ProjectName/Framework/" */
#include "Framework/GameState.h"
/* "Source/ProjectName/Player/" */
#include "Player/CharacterController.h"
//Must enter sub-folders as well, even though it's in the same subfolder
#include "Test/thisclass.h"
Side Notes:
- My attempts to google the solution kept showing results for changing the project location, not changing directories or include paths.
- I'm pretty sure this is a Visual Studio issue, but I'm using it with Unreal, so I tagged both.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加 publicCludePaths 到您的 * .build.cs
Add PublicIncludePaths to your *.Build.cs