标签: unreal-gameplay-ability-system

Unreal GAS:当属性发生变化时将其当前值打印到UI

当属性的基值更改时,可以UAttributeSet::PostGameplayEffectExecute()访问(新)值和GameplayEffect及其上下文。我用它来将更改后的值打印到 UI(这也在 ActionRPG 中完成)。

是否有类似的东西可用于属性的当前值?如何通知UI,何时FGameplayAttributeData::CurrentValue更新?


  • 尽管UAttributeSet::PreAttributeChange()在每次值更新时都会调用它,但它不提供任何上下文,因此无法从那里访问 UI(广播的事件FAggregator也不适合)。
  • 可以使用GameplayCue来代替,在 UI 中设置 的值FGameplayAttributeData::CurrentValue(提示由设置当前值的GameplayEffect触发)。这可以通过从 a 派生GameplayCueNotifyActor并使用其事件OnExecute和 来实现OnRemove。然而,仅仅为了更新 UI 而实例化一个 Actor 似乎是一种资源浪费。
  • It is also possible to fetch the information using the UI itself (calling a function which accesses the attribute each tick or with a timer), but in comparison to event driven UI update, this is also wasteful.

c++ unreal-engine4 unreal-gameplay-ability-system

3
推荐指数
1
解决办法
2847
查看次数