1 创建UI/Widget/AuraUserwidget

2 创建UI/WidgetController/AuraWidgetController UObject类

3在AuraUserWidget.h中

public:

  UFUNCTION(Blueprintcallable)

  void SetWidgetController(UObject* InWidgetController);

  UPROPERTY(BlueprintReadOnly)

  TObjectPtr<UObject> WodgetController;

protected:

  UFUNCTION(BlueprintImplementableEvent)

  void WidgetControllerSet();

4在AuraUserWidget.cpp中

SetWidgetController(UObject* InWidgetController)

{

  WidgetController = InWidgetController;

  WidgetControllerSet();

}

 

5在AuraWidgetController.h中

protected:

  UPROPERTY(BlueprintReadOnly,Categery="WidgetController")

  TObjectPtr<APlayerController>PlayerController;

 

  UPROPERTY(BlueprintReadOnly,Categery="WidgetController")

  TObjectPtr<APlayerState>PlayerState;

 

  UPROPERTY(BlueprintReadOnly,Categery="WidgetController")

  TObjectPtr<UAbilitySystemComponent>AbilitySystemComponent;

 

  UPROPERTY(BlueprintReadOnly,Categery="WidgetController")

  TObjectPtr<UAttributeSet>AttributeSet;

posted on 2025-08-17 10:47  偷懒的阿贤  阅读(11)  评论(0)    收藏  举报