Init
This commit is contained in:
97
03-UnrealEngine/Gameplay/Lyra/UE5 Lyra学习笔记(2)—LyraPlugins.md
Normal file
97
03-UnrealEngine/Gameplay/Lyra/UE5 Lyra学习笔记(2)—LyraPlugins.md
Normal file
@@ -0,0 +1,97 @@
|
||||
---
|
||||
title: UE5 Lyra学习笔记(2)—LyraPlugins
|
||||
date: 2022-08-09 13:55:20
|
||||
tags: Lyra Editor
|
||||
rating: ⭐️⭐️
|
||||
---
|
||||
# Plugins
|
||||
- AsyncMixin
|
||||
- CommonGame
|
||||
- CommonLoadingScreen
|
||||
- CommonUser
|
||||
- GameFeatures
|
||||
- GameplayMessageRouter
|
||||
- GameSettings
|
||||
- GameSubtitles
|
||||
- LyraExampleContent
|
||||
- LyraExtTool
|
||||
- ModularGameplayActors
|
||||
- PocketWorlds
|
||||
- UIExtension
|
||||
|
||||
## AsyncMixin
|
||||
|
||||
## ModularGameplayActors
|
||||
引擎插件ModularGameplay的Actor版本,增加了UGameFrameworkComponentManager控制的各种基础胶水类,Lyra里的相关类都继承自他们。
|
||||
- AModularGameModeBase(指定了插件里实现的类)
|
||||
- AModularAIController
|
||||
- AModularCharacter
|
||||
- AModularGameStateBase
|
||||
- AModularPawn
|
||||
- AModularPlayerController
|
||||
- AModularPlayerState
|
||||
|
||||
## UIExtension
|
||||
主要实现了`UUIExtensionPointWidget`这个控件以及用于数据控制的`UUIExtensionSubsystem`。`UUIExtensionPointWidget`是一个布局控件,实现一种以数据驱动方式,通过GameplayTag 匹配方式来插入Widget的方式。一般通过在UMG控件中设置参插槽参数;
|
||||
|
||||

|
||||

|
||||
|
||||
在LyraExperienceActionSet中设置AddWidgets(LayoutClass、LayoutID;WidgetClass、SlotID),最后会通过`UCommonUIExtensions::PushContentToLayer_ForPlayer`往屏幕上增加Widget。
|
||||

|
||||
|
||||
这样设计的其中一个优点在于实现解耦,例如:在相关Ability的Add/Remove进行UI注册与卸载,做到一个Ability做到所有的逻辑。
|
||||
|
||||
- UUIExtensionSubsystem
|
||||
- UUIExtensionHandleFunctions:通过FUIExtensionPointHandle判断有效性与卸载函数。
|
||||
- UUIExtensionPointHandleFunctions:通过FUIExtensionPointHandle判断有效性与卸载函数。
|
||||
- RegisterExtensionPointForContext:使用传入数据构建`FUIExtensionPoint`并其填充`ExtensionPointMap`,并且调用`ExtensionPoint`绑定的委托。
|
||||
- RegisterExtensionAsData:使用传入数据构建`FUIExtension`并其填充`ExtensionMap`,并且调用`Extension`绑定的委托。
|
||||
- UnregisterExtensionPoint:通过Handle移除对应`FUIExtensionPoint`。
|
||||
- UnregisterExtension:通过Handle移除对应`FUIExtension`。
|
||||
- 若干蓝图函数。
|
||||
- UMG控件
|
||||
- UUIExtensionPointWidget
|
||||
|
||||
AddWidgets代码位于`UGameFeatureAction_AddWidgets`类中。
|
||||
|
||||
## CommonUI
|
||||
- CommonUI官方文档:https://docs.unrealengine.com/5.0/zh-CN/overview-of-advanced-multiplatform-user-interfaces-with-common-ui-for-unreal-engine/
|
||||
- Introduction to Common UI:https://www.youtube.com/watch?v=TTB5y-03SnE
|
||||
- Lyra跨平台UI开发:https://www.bilibili.com/video/BV1mT4y167Fm?spm_id_from=333.999.0.0&vd_source=d47c0bb42f9c72fd7d74562185cee290
|
||||
|
||||
### CommonUIActionRouterBase
|
||||
这是一个本地玩家用的子系统。可以用于注册InputAction。
|
||||
|
||||
## GameplayMessageRouter
|
||||
Runtime模块实现了`UGameplayMessageSubsystem`与`UAsyncAction_ListenForGameplayMessage`;Editor模块实现了`UK2Node_AsyncAction_ListenForGameplayMessages`节点。
|
||||
|
||||
### FGameplayMessageListenerHandle
|
||||
存储了UGameplayMessageSubsystem的弱指针、Handle ID(int32 ID)、MessageChannel(FGameplayTag Channel)与FDelegateHandle。并且实现了Unregister()与IsValid()。
|
||||
|
||||
### UGameplayMessageSubsystem
|
||||
是一个UGameInstanceSubsystem。成员变量只有`ListenerMap`,记录MessageChannel=>FChannelListenerList的Map:
|
||||
```c++
|
||||
// List of all entries for a given channel
|
||||
struct FChannelListenerList
|
||||
{
|
||||
TArray<FGameplayMessageListenerData> Listeners;
|
||||
int32 HandleID = 0;
|
||||
};
|
||||
private:
|
||||
TMap<FGameplayTag, FChannelListenerList> ListenerMap;
|
||||
```
|
||||
|
||||
- 泛型函数:获取到类型的`UScriptStruct`传入内部函数,最后返回`FGameplayMessageListenerHandle`
|
||||
- RegisterListener
|
||||
- BroadcastMessage
|
||||
- UnregisterListener
|
||||
- 泛型函数调用的内部函数
|
||||
- RegisterListenerInternal:从使用MessageChannel(GameplayTag)从`ListenerMap`找到对应(如果没有则添加)的`FChannelListenerList`,并填充`FGameplayMessageListenerData`数据:仿函数以及其他相关信息。
|
||||
- BroadcastMessageInternal:调用对应MessageChannel(GameplayTag)与UScriptStruct类型的所有仿函数(该过程还会移除无效的仿函数所在项)。
|
||||
- UnregisterListenerInternal:从`ListenerMap`中找到对应MessageChannel(GameplayTag)的`FChannelListenerList`,并从其中移除指定HandleID的`FGameplayMessageListenerData`。如果之后`FChannelListenerList`为空,则从`ListenerMap`移除这个键值。
|
||||
|
||||
### UAsyncAction_ListenForGameplayMessage
|
||||
在Activate()中向`UGameplayMessageSubsystem`注册(Channel、Lambda、`TWeakObjectPtr<UScriptStruct> MessageStructType`、`EGameplayMessageMatch`)。lambda主要作用就是触发OnMessageReceived委托的多播。
|
||||
|
||||
UK2Node_AsyncAction_ListenForGameplayMessages为其封装的蓝图节点。
|
Reference in New Issue
Block a user