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

View File

@@ -0,0 +1,47 @@
# CommandLineID
- **功能描述:** 标记UMovieSceneCaptureProtocolBase的子类的协议类型。
- **使用位置:** UCLASS
- **引擎模块:** Sequencer
- **元数据类型:** string="abc"
- **限制类型:** UMovieSceneCaptureProtocolBase的子类上
- **常用程度:** ★★
标记UMovieSceneCaptureProtocolBase的子类的协议类型。
用来在Sequcencer渲染导出的时候选择到正确的处理类。一般也就引擎内部使用除非想自己自定义渲染输出的格式协议类。
## 测试效果:
![Untitled](Untitled.png)
## 原理:
简单来说就是通过选择的格式名字来找到相关的ProtocolType Class
```cpp
void UMovieSceneCapture::Initialize(TSharedPtr<FSceneViewport> InSceneViewport, int32 PIEInstance)
{
FString ImageProtocolOverrideString;
if ( FParse::Value( FCommandLine::Get(), TEXT( "-MovieFormat=" ), ImageProtocolOverrideString )
|| FParse::Value( FCommandLine::Get(), TEXT( "-ImageCaptureProtocol=" ), ImageProtocolOverrideString ) )
{
static const TCHAR* const CommandLineIDString = TEXT("CommandLineID");
TArray<UClass*> AllProtocolTypes = FindAllCaptureProtocolClasses();
for (UClass* Class : AllProtocolTypes)
{
bool bMetaDataMatch = Class->GetMetaData(CommandLineIDString) == ImageProtocolOverrideString;
if ( bMetaDataMatch || Class->GetName() == ImageProtocolOverrideString )
{
OverrideClass = Class;
}
}
ImageCaptureProtocolType = OverrideClass;
}
if (FParse::Value( FCommandLine::Get(), TEXT( "-AudioCaptureProtocol=" ), AudioProtocolOverrideString ) )
{
static const TCHAR* const CommandLineIDString = TEXT("CommandLineID");
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB

View File

@@ -0,0 +1,77 @@
# SequencerBindingResolverLibrary
- **功能描述:** 把具有SequencerBindingResolverLibrary标记的UBlueprintFunctionLibrary作为动态绑定的类。
- **使用位置:** UCLASS
- **引擎模块:** Sequencer
- **元数据类型:** bool
- **限制类型:** UClass上但一般是UBlueprintFunctionLibrary
- **常用程度:** ★★
把具有SequencerBindingResolverLibrary标记的UBlueprintFunctionLibrary作为动态绑定的类。只把它里面的函数添加到右键菜单里。
动态绑定是Sequencer的一个新功能简单来说就是允许设定好的轨迹变化动态应用到运行时的其他Actor上用来做Gameplay和Sequence的过度切换会很有用。更细致用法可以参考官方文档[https://dev.epicgames.com/documentation/zh-cn/unreal-engine/dynamic-binding-in-sequencer](https://dev.epicgames.com/documentation/zh-cn/unreal-engine/dynamic-binding-in-sequencer)
## 测试代码:
```cpp
UCLASS(meta=(SequencerBindingResolverLibrary), MinimalAPI)
class UMySequencerBindingResolverLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/** Resolve the bound object to the player's pawn */
UFUNCTION(BlueprintPure, Category="Sequencer|Insider", meta=(WorldContext="WorldContextObject"))
static FMovieSceneDynamicBindingResolveResult ResolveToMyActor(UObject* WorldContextObject, FString ActorTag);
};
```
源码:
```cpp
UCLASS(meta=(SequencerBindingResolverLibrary), MinimalAPI)
class UBuiltInDynamicBindingResolverLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/** Resolve the bound object to the player's pawn */
UFUNCTION(BlueprintPure, Category="Sequencer|Dynamic Binding", meta=(WorldContext="WorldContextObject"))
static MOVIESCENE_API FMovieSceneDynamicBindingResolveResult ResolveToPlayerPawn(UObject* WorldContextObject, int32 PlayerControllerIndex = 0);
};
```
## 测试结果:
在没有定义UMySequencerBindingResolverLibrary 之前引擎里有个内建的ResolveToPlayerPawn可以把PlayerControllerIndex 解析为Pawn来动态绑定到玩家的Pawn。
因此我们也可以定义自己的动态绑定函数来解析一个FString为一个Actor如代码里ResolveToMyActor所示。
![Untitled](Untitled.png)
## 原理:
FMovieSceneDynamicBindingCustomization会搜索引擎里的所有类但为了缩减范围因此只有在标有SequencerBindingResolverLibrary的类下面才去发现Resolver函数。
```cpp
void FMovieSceneDynamicBindingCustomization::CollectResolverLibraryBindActions(UBlueprint* Blueprint, FBlueprintActionMenuBuilder& MenuBuilder, bool bIsRebinding)
{
// Add any class that has the "SequencerBindingResolverLibrary" meta as a target class.
//
// We don't consider *all* blueprint function libraries because there are many, many of them that expose
// functions that are, technically speaking, compatible with bound object resolution (i.e. they return
// a UObject pointer) but that are completely non-sensical in this context.
const static FName SequencerBindingResolverLibraryMeta("SequencerBindingResolverLibrary");
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
{
UClass* CurrentClass = *ClassIt;
if (CurrentClass->HasMetaData(SequencerBindingResolverLibraryMeta))
{
FBlueprintActionFilter::Add(MenuFilter.TargetClasses, CurrentClass);
}
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 KiB

View File

@@ -0,0 +1,50 @@
# TakeRecorderDisplayName
- **功能描述:** 指定UTakeRecorderSource的显示名字。
- **使用位置:** UCLASS
- **引擎模块:** Sequencer
- **元数据类型:** string="abc"
- **限制类型:** UTakeRecorderSource的子类上
- **常用程度:** ★★
指定UTakeRecorderSource的显示名字。
这个一般是引擎内部自己用除非想自己自定义UTakeRecorderSource才会派上用场。因为原理和展示过于简单因此就不自己构建测试代码。
## 源码例子:
```cpp
UCLASS(Category="Actors", meta = (TakeRecorderDisplayName = "Player"))
class UTakeRecorderPlayerSource : public UTakeRecorderSource
{}
```
## 测试效果:
在引擎源码中可见有多个UTakeRecorderSource其上都标了名字。
![Untitled](Untitled.png)
## 原理:
用TakeRecorderDisplayName指定的名字来作为菜单项的名字。
```cpp
TSharedRef<SWidget> SLevelSequenceTakeEditor::OnGenerateSourcesMenu()
{
for (UClass* Class : SourceClasses)
{
TSubclassOf<UTakeRecorderSource> SubclassOf = Class;
MenuBuilder.AddMenuEntry(
FText::FromString(Class->GetMetaData(TEXT("TakeRecorderDisplayName"))),
Class->GetToolTipText(true),
FSlateIconFinder::FindIconForClass(Class),
FUIAction(
FExecuteAction::CreateSP(this, &SLevelSequenceTakeEditor::AddSourceFromClass, SubclassOf),
FCanExecuteAction::CreateSP(this, &SLevelSequenceTakeEditor::CanAddSourceFromClass, SubclassOf)
)
);
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 KiB