dubaiworld 发表于 2019-10-3 23:18:55

UE4_C++莫名其妙的错误

<blockquote>1>Module.SlAiCourse.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UWidgetComponent_NoRegister(void)" (__imp_?Z_Construct_UClass_UWidgetComponent_NoRegister@@YAPEAVUClass@@XZ) referenced in function "class UClass * __cdecl Z_Construct_UClass_ASlAiEnemyCharacter(void)" (?Z_Construct_UClass_ASlAiEnemyCharacter@@YAPEAVUClass@@XZ)引擎用的是UE4.19
VS2017
这是到底什么错误啊,难道UWidgetComponent在继承自ACharacter的类不能用吗?

dubaiworld 发表于 2019-10-4 00:09:28

我自己新建了一个工程,自带ThirdPersionCharacter类,然后我在.h文件中加入了
protected:
        //血条
        UPROPERTY(EditAnywhere, Category = Mesh)
                class UWidgetComponent* HealthUICompo;
报了同样的错误,是不是UWidgetComponent类在无法在ACharacter中引用啊

rrfetch 发表于 2019-10-4 10:40:34

https://wiki.unrealengine.com/UMG,_Referencing_UMG_Widgets_in_Code
你是不是忘了官方文档中的第一步
1. Adding Modules:

in order to use UMG in C++ you need to Add the following Modules in ProjectNameBuild.CS file

"UMG", "Slate", "SlateCore

In this line:

//ProjectNameBuild.CS

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore" });

dubaiworld 发表于 2019-10-4 12:52:40

rrfetch 发表于 2019-10-4 10:40
https://wiki.unrealengine.com/UMG,_Referencing_UMG_Widgets_in_Code
你是不是忘了官方文档中的第一步
1. ...

谢谢,是的,重要的事情给完全忘记了

azdsaz 发表于 2020-5-3 06:08:18

重要的事情给完全忘记了

he18607794620 发表于 2024-3-3 02:45:01

谢谢大佬
页: [1]
查看完整版本: UE4_C++莫名其妙的错误