BlueRoseNote/03-UnrealEngine/Gameplay/GAS/(14)GameplayAbility Debug方法.md
2023-06-29 11:55:02 +08:00

53 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 前言
之前一直都没有研究过GAS如何debug所以大致翻译了相关内容
>https://github.com/tranek/GASDocumentation#debugging
中文翻译
>https://blog.csdn.net/pirate310/article/details/106311256
# C++ Debug Tip
在非DebugGame Editor模式下模式下Ue4会对函数进行优化这会对debug产生一定阻碍。解决方法是
1. 在VisualStudio中将解决方案设置SolutionConfigurations改成DebugGame Editor之后再进行调试。
2. 对想要进行Debug的函数增加禁用所有优化的宏。
使用方法如下:
```
PRAGMA_DISABLE_OPTIMIZATION_ACTUAL
void MyClass::MyFunction(int32 MyIntParameter)
{
// My code
}
PRAGMA_ENABLE_OPTIMIZATION_ACTUAL
```
如果在插件中使用则需要对插件执行rebuild以进行重新构建。最后记得在调试完成后将宏删除。
# 自带的Debug工具
## showdebug abilitysystem
**显示方法**:按“`”键输入命令:showdebug abilitysystem。这个界面总共三页内容分别显示Attributes、Effects、Abilities。通过**AbilitySystem.Debug.NextCategory**命令进行翻页。
![image](https://cdn.jsdelivr.net/gh/tranek/GASDocumentation@master/Images/showdebugpage1.png)
![image](https://cdn.jsdelivr.net/gh/tranek/GASDocumentation@master/Images/showdebugpage2.png)
![image](https://cdn.jsdelivr.net/gh/tranek/GASDocumentation@master/Images/showdebugpage3.png)
PS.PageUp与PageDown可以切换目标。
## GameplayDebugger
![image](https://cdn.jsdelivr.net/gh/tranek/GASDocumentation@master/Images/gameplaydebugger.png)
在进入关卡后,按下“’”键就可以开启这个工具。(就是屏幕上方出现的工具栏)
这个功能感觉是用来调试非当前操作角色的,选中的角色上会出现一个红色小恶魔图标(如图所示),你可以小键盘的数字键来开启对应的功能。
可以通过Tab键切换成飞行模式来选中需要调试角色。
# GameEffect增加/减少 委托绑定
```
AbilitySystemComponent->OnActiveGameplayEffectAddedDelegateToSelf.AddUObject(this, &APACharacterBase::OnActiveGameplayEffectAddedCallback);
```
```
AbilitySystemComponent->OnAnyGameplayEffectRemovedDelegate().AddUObject(this, &APACharacterBase::OnRemoveGameplayEffectCallback);
```