Unreal Vs C++: #Include “.generated.h” cannot be found after #include “.h” from my plugin file

huangapple go评论75阅读模式
英文:

Unreal Vs C++: #Include ".generated.h" cannot be found after #include ".h" from my plugin file

问题

我正在按照如何在虚幻引擎中创建有限状态机插件的指南。当我在我的插件中的.h文件#include到我的虚幻C++类中时,出现了一个问题。问题在于,当我#include "StateManagerComponent.h"(插件类)到"GoblinFSM.h"(虚幻类)时,使用了完整的文件路径,我的代码就无法找到"StateManagerComponent.generated.h"。

我已经在我的项目的VC++目录中添加了这两个路径,希望我的项目能够同时找到"StateManagerComponent.generated.h"文件和"StateManagerComponent.h"文件。不幸的是,这只给我带来了大约10,000个错误。真的不知道从哪里开始解决这个问题。

英文:

I'm following a guide on how to make a finite state machine plugin in Unreal Engine. I have ran into an issue when I #include a .h file from my plugin into my Unreal C++ class. The issue is that when I #include "StateManagerComponent.h" (Plugin Class) into "GoblinFSM.h" (Unreal Class) with its total relevant file path, my code stops being able to find "StateManagerComponent.generated.h"

Unreal Vs C++: #Include “.generated.h” cannot be found after #include “.h” from my plugin file

Unreal Vs C++: #Include “.generated.h” cannot be found after #include “.h” from my plugin file

I have added both paths to the include in my project's VC++ Directories hoping that my project would then be able to find the StateManagerComponent.generated.h file and the StateManagerComponent.h file at the same time. Unfortunately, it just gave me ~10,000 errors. Really don't know where to go from here.

答案1

得分: 1

I noticed that you're importing the whole absolute path of your machine to include the StateManagerComponent.h. You don't have to do that as Unreal Engine Build Tools set up the visual studio solution so that every reference can be made relative.

If you need to include the StateMachinePlugin\Public path on your header file will depend on how you set up your Build.cs file. You can look at how Epic set it up in all modules across the engine. Here's more info about it: https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/ProgrammingWithCPP/Modules/

If you already made changes to your Visual Studio project or solution files I suggest that you delete your .vs, your sln and your intermediate files and regenerate the Visual Studio files from within Unreal Engine or using the context menu in Windows Explorer.

The generated files will always live in your Intermediate/Build folder and will have all the info needed from the UCLASS, UFUNCTION, etc macros.

英文:

I noticed that you're importing the whole absolute path of your machine to include the StateManagerComponent.h. You don't have to do that as Unreal Engine Build Tools set up the visual studio solution so that every reference can be made relative.

If you need to include the StateMachinePlugin\Public path on your header file will depend on how you set up your Build.cs file. You can look at how Epic set it up in all modules across the engine. Here's more info about it: https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/ProgrammingWithCPP/Modules/

If you already made changes to your Visual Studio project or solution files I suggest that you delete your .vs, your sln and your intermediate files and regenerate the Visual Studio files from within Unreal Engine or using the context menu in Windows Explorer.

The generated files will always live in your Intermediate/Build folder and will have all the info needed from the UCLASS, UFUNCTION, etc macros.

huangapple
  • 本文由 发表于 2023年2月27日 11:51:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75576638.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定