.obsidian
.vs
00-MOC
01-Diary
02-Note
03-UnrealEngine
Animation
Editor
Gameplay
AI
Animation
Code
Debug
GAS
Gameplay
Http
Lyra
Mass
Online
Other
PuerTS
UObject
UnrealSpecifiers
Flags
Meta
Specifier
UCLASS
UENUM
UFUNCTION
UINTERFACE
UPARAM
UPROPERTY
USTRUCT
Blueprint
Serialization
UHT
Atomic
NoExport
HasDefaults.md
HasNoOpConstructor.md
IsAlwaysAccessible.md
IsCoreType.md
UCLASS.md
UENUM.md
UFUNCTION.md
UINTERFACE.md
UPARAM.md
UPROPERTY.md
USTRUCT.md
UnrealSpecifiers.md
Ue4 c++ UProperty反射 PostEditChangeProperty.md
Ue4Object生命周期.jpg
大钊提供的一种获取UE Private函数的方法.md
LevelScene
Math
Mobile
Plugins
Rendering
Sequence
UI
VirtualProduction
VisualEffect
卡通渲染相关资料
性能优化
流程管理与部署
.keep
03-UnrealEngine.md
04-ComputerGraphics
05-SDHGame
06-DCC
07-Other
08-Assets
09-Templates
.gitattributes
.gitignore
.gitmodules
LICENSE
42 lines
1.5 KiB
Markdown
42 lines
1.5 KiB
Markdown
|
# HasDefaults
|
|||
|
|
|||
|
- **功能描述:** 指定该结构的字段拥有默认值。这样如果本结构作为函数参数或返回值时候,函数则可以为其提供默认值。
|
|||
|
- **元数据类型:** bool
|
|||
|
- **引擎模块:** UHT
|
|||
|
- **限制类型:** 只在NoExportTypes.h供UHT使用
|
|||
|
- **作用机制:** 在FunctionFlags中加入[FUNC_HasDefaults](../../../Flags/EFunctionFlags/FUNC_HasDefaults.md)
|
|||
|
- **常用程度:** 0
|
|||
|
|
|||
|
指定该结构的字段拥有默认值。
|
|||
|
|
|||
|
不是指的是NoExportTypes.h的声明上是否写有默认值,而是指其真正的声明之处,其内部的属性都有初始值。这样如果本结构作为函数参数或返回值时候,函数则可以为其提供默认值。
|
|||
|
|
|||
|
NoExportTypes.h里的大部分结构都拥有该结构(88/135),没有的是像FPackedXXX的。
|
|||
|
|
|||
|
## 原理:
|
|||
|
|
|||
|
如果是一个class中的函数且参数用到了结构,如果该结构拥有HasDefaults,则会造成EFunctionFlags.HasDefaults
|
|||
|
|
|||
|
```cpp
|
|||
|
// The following code is only performed on functions in a class.
|
|||
|
if (Outer is UhtClass)
|
|||
|
{
|
|||
|
foreach (UhtType type in Children)
|
|||
|
{
|
|||
|
if (type is UhtProperty property)
|
|||
|
{
|
|||
|
if (property.PropertyFlags.HasExactFlags(EPropertyFlags.OutParm | EPropertyFlags.ReturnParm, EPropertyFlags.OutParm))
|
|||
|
{
|
|||
|
FunctionFlags |= EFunctionFlags.HasOutParms;
|
|||
|
}
|
|||
|
if (property is UhtStructProperty structProperty)
|
|||
|
{
|
|||
|
if (structProperty.ScriptStruct.HasDefaults)
|
|||
|
{
|
|||
|
FunctionFlags |= EFunctionFlags.HasDefaults;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
```
|