【问题标题】:What is this c++ syntax called这个 c++ 语法叫什么
【发布时间】:2021-04-22 08:21:50
【问题描述】:

我一直在学习 c++ 并完成了很多语法任务,但是当我尝试进入虚幻引擎时,我偶然发现了一种我似乎不熟悉的语法。

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) /*what is this?? I could pretty 
much understand anything written below except for this single line */

class ESCAPE_ROOM_API UPositionReporter : public UActorComponent
{
    GENERATED_BODY()

public: 
    // Sets default values for this component's properties
    UPositionReporter();

protected:
    // Called when the game starts
    virtual void BeginPlay() override;

public: 
    // Called every frame
    virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* 
    ThisTickFunction) override;

    
};

【问题讨论】:

  • 似乎有预处理器宏在起作用,如果没有该代码的更多上下文,我们无法知道。
  • 您提供了哪些宏?一些代码库有非常,啊,你可以称它们为creative 宏定义。该代码可能会扩展为最终被编译的其他内容。
  • UCLASS 是一个定义/宏。你必须向我们展示它是什么。 (在代码中查找#define UCLASS)。
  • UCLASS 不只是虚幻引擎的一部分吗?找不到文档链接,但网络上的各种消息来源说它用于在引擎中注册某些内容。
  • 您是否尝试过用谷歌搜索 UCLASS,它显示为虚幻引擎似乎用于反射的元信息系统的一部分。

标签: c++ unreal-engine4 unreal-blueprint


【解决方案1】:

UCLASS 是虚幻引擎定义的自定义预处理器宏。您可以使用它使引擎了解您的自定义类,并向它们添加某些称为说明符的元数据。 on this page of the documentation 提供了可能的说明符列表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-10
    • 2016-11-06
    • 1970-01-01
    • 2018-12-17
    • 1970-01-01
    • 2010-11-10
    • 2011-05-18
    • 2020-06-21
    相关资源
    最近更新 更多