vault backup: 2024-10-12 17:19:45

This commit is contained in:
2024-10-12 17:19:46 +08:00
parent ff94ddca61
commit 244c0c52f6
960 changed files with 31348 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

@@ -0,0 +1,48 @@
# Comment
- **功能描述:** 用来记录注释的内容
- **使用位置:** Any
- **引擎模块:** Development
- **元数据类型:** string="abc"
- **常用程度:** ★★★
Comment跟ToolTip不同后者是用户鼠标悬停上的提示前者只是简单的代码中的注释的记录。但是一般我们在代码里写上的注释会自动也加到ToolTip 上因此我们往往也会看到UI界面上的提示。
但如果不想要ToolTip想只有Comment则也可以自己手动在meta里添加。
## 测试代码:
```cpp
//(BlueprintType = true, Comment = //This is a comment on class, IncludePath = Property/Development/MyProperty_Development.h, ModuleRelativePath = Property/Development/MyProperty_Development.h, ToolTip = This is a comment on class)
//This is a comment on class
UCLASS(BlueprintType)
class INSIDER_API UMyProperty_Development :public UObject
{
GENERATED_BODY()
public:
//(Comment = //This is a comment on function, ModuleRelativePath = Property/Development/MyProperty_Development.h, ToolTip = This is a comment on function)
//This is a comment on function
UFUNCTION(BlueprintCallable)
int32 MyFunc(FString str){return 0;}
// (Category = MyProperty_Development, Comment = //This is a comment on property, ModuleRelativePath = Property/Development/MyProperty_Development.h, ToolTip = This is a comment on property)
//This is a comment on property
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 MyProperty = 123;
//(Category = MyProperty_Development, Comment = This is my other property., ModuleRelativePath = Property/Development/MyProperty_Development.h)
UPROPERTY(EditAnywhere, BlueprintReadWrite,meta=(Comment="This is my other property."))
int32 MyProperty_WithComment = 123;
};
```
## 测试结果:
MyProperty_WithComment是单独只加的Comment就没有了鼠标悬停效果。
![Comment](Comment.gif)

View File

@@ -0,0 +1,13 @@
# Deprecated
- **功能描述:** 指定该元素要废弃的引擎版本号。
- **使用位置:** Any
- **引擎模块:** Development
- **元数据类型:** string="abc"
- **常用程度:** ★
指定该元素要废弃的引擎版本号。
这个值只是单纯的在C++代码中记录一下信息并不会真正的使得一个元素变成废弃。这个值也没有在别的地方UI使用和显示出来。
要废弃一个元素,还是要用别的标记,如**DeprecatedPropertyDeprecatedFunction等。**

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,9 @@
# DeprecatedFunction
- **功能描述:** 标明一个函数已经被弃用
- **使用位置:** UFUNCTION
- **引擎模块:** Development
- **元数据类型:** bool
- **常用程度:** ★
*Any Blueprint references to this function will cause compilation warnings telling the user that the function is deprecated. You can add to the deprecation warning message (for example, to provide instructions on replacing the deprecated function) using the DeprecationMessage metadata specifier.*

View File

@@ -0,0 +1,33 @@
# DeprecatedProperty
- **功能描述:** 标记弃用,引用到该属性的蓝图会触发一个警告
- **使用位置:** UPROPERTY
- **引擎模块:** Development
- **元数据类型:** bool
- **关联项:**
UCLASS[Deprecated](../../../Specifier/UCLASS/Development/Deprecated/Deprecated.md)
- **常用程度:** ★
标记弃用,引用到该属性的蓝图会触发一个警告
## 示例代码:
```cpp
// Simple
UPROPERTY(BlueprintReadWrite, meta=(DeprecatedProperty, DeprecationMessage="This is deprecated"))
FString PlantName;
// Better
UPROPERTY(BlueprintReadWrite, meta=(DisplayName="PlantName", DeprecatedProperty, DeprecationMessage="PlantName is deprecated, instead use PlantDisplayName."))
FString DEPRECATED_PlantName;
```
![Untitled](Untitled.png)
![Untitled%201](Untitled%201.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

@@ -0,0 +1,25 @@
# DeprecationMessage
- **功能描述:** 定义弃用的消息
- **使用位置:** UCLASS, UFUNCTION, UPROPERTY
- **引擎模块:** Development
- **元数据类型:** string="abc"
- **关联项:**
UCLASS[Deprecated](../../Specifier/UCLASS/Development/Deprecated/Deprecated.md)
- **常用程度:** ★
## 例子:
```cpp
UFUNCTION(meta=(DeprecatedFunction,DeprecationMessage="This function is deprecated, please use OtherFunctionName instead."))
ReturnType FunctionName([Parameter, Parameter, ...])
UPROPERTY(BlueprintReadWrite, meta=(DeprecatedProperty, DeprecationMessage="This is deprecated"))
FString PlantName;
```

View File

@@ -0,0 +1,48 @@
# DevelopmentOnly
- **功能描述:** 使得一个函数变为DevelopmentOnly意味着只会在Development模式中运行。适用于调试输出之类的功能但在最终发布版中会跳过。
- **使用位置:** UFUNCTION
- **引擎模块:** Development
- **元数据类型:** bool
- **常用程度:** ★
使得一个函数变为DevelopmentOnly意味着只会在Development模式中运行。适用于调试输出之类的功能但在最终发布版中会跳过。
源码中最典型的例子就是PrintString。
## 测试代码:
```cpp
UFUNCTION(BlueprintCallable,meta=(DevelopmentOnly))
static void MyFunc_DevelopmentOnly(){}
UFUNCTION(BlueprintCallable,meta=())
static void MyFunc_NotDevelopmentOnly(){}
```
## 蓝图效果:
![Untitled](Untitled.png)
## 原理:
其会改变这个函数蓝图节点的状态为DevelopmentOnly从而最终导致该node在shipping模式下被pass through。
```cpp
void UK2Node_CallFunction::Serialize(FArchive& Ar)
{
if (const UFunction* Function = GetTargetFunction())
{
// Enable as development-only if specified in metadata. This way existing functions that have the metadata added to them will get their enabled state fixed up on load.
if (GetDesiredEnabledState() == ENodeEnabledState::Enabled && Function->HasMetaData(FBlueprintMetadata::MD_DevelopmentOnly))
{
SetEnabledState(ENodeEnabledState::DevelopmentOnly, /*bUserAction=*/ false);
}
// Ensure that if the metadata is removed, we also fix up the enabled state to avoid leaving it set as development-only in that case.
else if (GetDesiredEnabledState() == ENodeEnabledState::DevelopmentOnly && !Function->HasMetaData(FBlueprintMetadata::MD_DevelopmentOnly))
{
SetEnabledState(ENodeEnabledState::Enabled, /*bUserAction=*/ false);
}
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@@ -0,0 +1,18 @@
# DevelopmentStatus
- **功能描述:** 标明开发状态
- **使用位置:** UCLASS
- **引擎模块:** Development
- **元数据类型:** string="abc"
- **关联项:**
UCLASS[Experimental](../../Specifier/UCLASS/Development/Experimental/Experimental.md), [EarlyAccessPreview](../../Specifier/UCLASS/Development/EarlyAccessPreview/EarlyAccessPreview.md)
- **常用程度:** ★
DevelopmentStatus=Experimental
DevelopmentStatus=EarlyAccess

View File

@@ -0,0 +1,6 @@
# FriendlyName
- **功能描述:** 和DisplayName一样
- **使用位置:** Any
- **引擎模块:** Development
- **元数据类型:** string="abc"

View File

@@ -0,0 +1,6 @@
# ShortTooltip
- **功能描述:** 提供一个更简洁版本的提示文本,例如在类型选择器的时候显示
- **使用位置:** Any
- **元数据类型:** string="abc"
- **关联项:** [ToolTip](ToolTip/ToolTip.md)

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -0,0 +1,231 @@
# ToolTip
- **功能描述:** 在Meta里提供一个提示文本覆盖代码注释里的文本
- **使用位置:** Any
- **引擎模块:** Development
- **元数据类型:** string="abc"
- **关联项:** [ShortTooltip](../ShortTooltip.md)
- **常用程度:** ★★★
## 测试代码:
```cpp
// This is a ToolTip out of Class.There're so so so so so so so many words I want to say, but here's too narrow.
UCLASS(BlueprintType, Blueprintable, meta = (ToolTip = "This is a ToolTip within Class. There're so so so so so so so many words I want to say, but here's too narrow."))
class INSIDER_API UMyClass_ToolTip :public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "This is a ToolTip within Property.There're so so so so so so so many words I want to say, but here's too narrow."))
float MyFloat_WithToolTip;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString MyString;
UFUNCTION(BlueprintCallable, meta = (ToolTip = "This is a ToolTip within Function.There're so so so so so so so many words I want to say, but here's too narrow."))
void MyFunc_WithToolTip() {}
UFUNCTION(BlueprintCallable)
void MyFunc() {}
};
// This is a ToolTip out of Class.There're so so so so so so so many words I want to say, but here's too narrow.
UCLASS(BlueprintType, Blueprintable, meta = (ToolTip = "This is a ToolTip within Class. There're so so so so so so so many words I want to say, but here's too narrow.", ShortToolTip = "This is a ShortToolTip within Class."))
class INSIDER_API UMyClass_WithAllToolTip :public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "This is a ToolTip within Property."))
float MyFloat_WithToolTip;
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ToolTip = "This is a ToolTip within Property. There're so so so so so so so many words I want to say, but here's too narrow.\nThis is a new line.",ShortToolTip = "This is a ShortToolTip within Property."))
float MyFloat_WithAllToolTip;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FString MyString;
UFUNCTION(BlueprintCallable, meta = (ToolTip = "This is a ToolTip within Function. There're so so so so so so so many words I want to say, but here's too narrow.",ShortToolTip = "This is a ShortToolTip within Function."))
void MyFunc_WithAllToolTip() {}
UFUNCTION(BlueprintCallable, meta = (ToolTip = "This is a ToolTip within Function."))
void MyFunc_WithToolTip() {}
};
// This is a ToolTip out of Class.There're so so so so so so so many words I want to say, but here's too narrow.
UCLASS(BlueprintType, Blueprintable)
class INSIDER_API UMyClass_ToolTip_TypeA :public UObject
{
GENERATED_BODY()
};
/**
* This is a ToolTip out of Class.
* There're so so so so so so so many words I want to say, but here's too narrow.
* Please read this tooltip before you use this class.
*/
UCLASS(BlueprintType, Blueprintable)
class INSIDER_API UMyClass_ToolTip_TypeB :public UObject
{
GENERATED_BODY()
};
```
## 测试效果:
在选取父类时候的提示:
可以发现如果提供了ToolTip就会覆盖掉代码注释里的注释。同时也可以发现在下图中提示的文本过长超过了选项框。这时如果提供了ShortToolTip则会在父类选取器中显示ShortToolTip中的文本从而简洁一点显示。在很多别的地方也同样应用这个规则比如该类型变量上的提示或者在选择变量类型的时候。
![1234](1234.png)
## 原理代码:
在源码里有FField和UField普通的属性是FField而像UClass是继承于UField因此要注意FField::GetToolTipText的bShortTooltip一直是false而UField::GetToolTipText则会传true。
```cpp
FText FField::GetToolTipText(bool bShortTooltip) const
{
bool bFoundShortTooltip = false;
static const FName NAME_Tooltip(TEXT("Tooltip"));
static const FName NAME_ShortTooltip(TEXT("ShortTooltip"));
FText LocalizedToolTip;
FString NativeToolTip;
if (bShortTooltip)
{
NativeToolTip = GetMetaData(NAME_ShortTooltip);
if (NativeToolTip.IsEmpty())
{
NativeToolTip = GetMetaData(NAME_Tooltip);
}
else
{
bFoundShortTooltip = true;
}
}
else
{
NativeToolTip = GetMetaData(NAME_Tooltip);
}
const FString Namespace = bFoundShortTooltip ? TEXT("UObjectShortTooltips") : TEXT("UObjectToolTips");
const FString Key = GetFullGroupName(false);
if (!FText::FindText(Namespace, Key, /*OUT*/LocalizedToolTip, &NativeToolTip))
{
if (!NativeToolTip.IsEmpty())
{
static const FString DoxygenSee(TEXT("@see"));
static const FString TooltipSee(TEXT("See:"));
if (NativeToolTip.ReplaceInline(*DoxygenSee, *TooltipSee) > 0)
{
NativeToolTip.TrimEndInline();
}
}
LocalizedToolTip = FText::FromString(NativeToolTip);
}
return LocalizedToolTip;
}
FText UField::GetToolTipText(bool bShortTooltip) const
{
bool bFoundShortTooltip = false;
static const FName NAME_Tooltip(TEXT("Tooltip"));
static const FName NAME_ShortTooltip(TEXT("ShortTooltip"));
FText LocalizedToolTip;
FString NativeToolTip;
if (bShortTooltip)
{
NativeToolTip = GetMetaData(NAME_ShortTooltip);
if (NativeToolTip.IsEmpty())
{
NativeToolTip = GetMetaData(NAME_Tooltip);
}
else
{
bFoundShortTooltip = true;
}
}
else
{
NativeToolTip = GetMetaData(NAME_Tooltip);
}
const FString Namespace = bFoundShortTooltip ? TEXT("UObjectShortTooltips") : TEXT("UObjectToolTips");
const FString Key = GetFullGroupName(false);
if ( !FText::FindText( Namespace, Key, /*OUT*/LocalizedToolTip, &NativeToolTip ) )
{
if (NativeToolTip.IsEmpty())
{
NativeToolTip = FName::NameToDisplayString(FDisplayNameHelper::Get(*this), false);
}
else if (!bShortTooltip && IsNative())
{
FormatNativeToolTip(NativeToolTip, true);
}
LocalizedToolTip = FText::FromString(NativeToolTip);
}
return LocalizedToolTip;
}
//在类型选择器中优先选择ShortTooltip
FText FClassPickerDefaults::GetDescription() const
{
FText Result = LOCTEXT("NullClass", "(null class)");
if (UClass* ItemClass = LoadClass<UObject>(NULL, *ClassName, NULL, LOAD_None, NULL))
{
Result = ItemClass->GetToolTipText(/*bShortTooltip=*/ true);
}
return Result;
}
```
但对于Property和Function在显示的时候都只会显示ToolTip并不会应用ShortToolTip
变量和函数:
![55](55.png)
![77](77.png)
其他需要注意的是代码里注释的文本也会当作ToolTip。支持//和/**/这两种格式。如果在ToolTip中想换行可以直接加/n就可以。
```cpp
/*
(BlueprintType = true, Comment = // This is a ToolTip out of Class.There're so so so so so so so many words I want to say, but here's too narrow.
, IncludePath = Any/ToolTip_Test.h, IsBlueprintBase = true, ModuleRelativePath = Any/ToolTip_Test.h, ToolTip = This is a ToolTip out of Class.There're so so so so so so so many words I want to say, but here's too narrow.)
*/
// This is a ToolTip out of Class.There're so so so so so so so many words I want to say, but here's too narrow.
UCLASS(BlueprintType, Blueprintable)
class INSIDER_API UMyClass_ToolTip_TypeA :public UObject
{
GENERATED_BODY()
};
//[MyClass_ToolTip_TypeB Class->Struct->Field->Object /Script/Insider.MyClass_ToolTip_TypeB]
//(BlueprintType = true, Comment = /**
//* This is a ToolTip out of Class.
//* There're so so so so so so so many words I want to say, but here's too narrow.
//* Please read this tooltip before you use this class.
//*/, IncludePath = Any/ToolTip_Test.h, IsBlueprintBase = true, ModuleRelativePath = Any/ToolTip_Test.h, ToolTip = This is a ToolTip out of Class.
//There're so so so so so so so many words I want to say, but here's too narrow.
//Please read this tooltip before you use this class.)
/**
* This is a ToolTip out of Class.
* There're so so so so so so so many words I want to say, but here's too narrow.
* Please read this tooltip before you use this class.
*/
UCLASS(BlueprintType, Blueprintable)
class INSIDER_API UMyClass_ToolTip_TypeB :public UObject
{
GENERATED_BODY()
};
UCLASS(BlueprintType, Blueprintable, meta = (ToolTip = "This is a ToolTip within Class. There're so so so so so so so many words I want to say, but here's too narrow.\nThis is a new line.", ShortToolTip = "This is a ShortToolTip within Class."))
```