简体   繁体   English

在虚幻引擎中创建对象?

[英]Create objects in unreal engine?

I have to create object like this:我必须像这样创建 object :

UStaticMeshComponent* staticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CustomStaticMesh"));

But I don't get how this works.但我不明白这是如何工作的。 Why do I add that angle bracket?为什么要添加那个尖括号? I understand it has to do with templates but can't find the syntax for using template this way,我知道它与模板有关,但找不到以这种方式使用模板的语法,

and is CreateDefaultSubobject a static function so I can call it without instantiating?并且 CreateDefaultSubobject 是 static function 所以我可以在不实例化的情况下调用它吗?

CreateDefaultSubObject is only to be used inside of Constructors. CreateDefaultSubObject只能在构造函数内部使用。

Use NewObject or in the case of an AActor derived class UWorld::SpawnActor to create these objects respectively outside of the constructor, typically at runtime.使用NewObject或在 AActor 派生的 class UWorld::SpawnActor的情况下分别在构造函数之外创建这些对象,通常是在运行时。

The <> denotes the template type passed to the function. <>表示传递给 function 的模板类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM