默认/样板代码在Visual Studio 2017中给我错误.E1574.虚幻.但构建成功了
Default/boilerplate code gives me error in Visual Studio 2017. E1574. Unreal. But Build Succeeded
我正在尝试学习UE4,但目前我被困在做一些非常简单的事情上。我想创建一个突破样式"划桨"作为蓝图。
但是我有一个奇怪的问题,我的代码对我来说看起来不错(我直接从导师视频中复制代码(,但在 Visual Studio 中我收到错误:E1574 静态断言失败,并显示"TAtomic 只能用于普通类型"。我甚至删除了所有代码,只保留了UE4提供的默认代码(当我点击"创建C++类>Actor"时(。构建该错误时仍然存在。
我得到的另一个问题是,对于我在代码中实例化的 StaticMeshComponent,Paddle_BP中的"详细信息"面板是空的。在本教程中,它提供了一个静态网格组件,您可以在其中选择网格,添加物理和其他选项。
这是我的代码:
桨:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Paddle.generated.h"
UCLASS()
class SHIT_PONG_CPP_API APaddle : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
APaddle();
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "ActorMeshComponents")
UStaticMeshComponent* StaticMesh;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
划桨.cpp
#include "Paddle.h"
// Sets default values
APaddle::APaddle()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CustomStaticMesh"));
}
// Called when the game starts or when spawned
void APaddle::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APaddle::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
我已经阅读了这个线程(静态断言失败,并显示"Windows 标头需要默认打包选项......"( 和 Microsoft (https://learn.microsoft.com/en-us/cpp/build/reference/zp-struct-member-alignment?view=vs-2019( 中有关更改编译器设置的页面。但是说明似乎已经过时了,我根本无法在我的选项中找到"> C/C++> 代码生成的配置属性"。
我认为当你在Visual Studio中构建时会发生此错误。我认为如果您从UE环境中编译,则可以避免此错误。以下是来自虚幻论坛的链接,它提出了相同的解决方案:https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1703131-error-static-assertion-failed-with-tatomic-is-only-usable-with-trivial-types
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 默认/样板代码在Visual Studio 2017中给我错误.E1574.虚幻.但构建成功了