Files
PHY/Source/PHY/Private/UI/Widget/Widget_NotifyItem.h
2026-03-05 01:34:47 +08:00

75 lines
1.9 KiB
C++
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.
// Copyright 2025 PHY. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Widget_NotifyItem.generated.h"
class UTextBlock;
class UImage;
class UTexture2D;
UCLASS()
class PHY_API UWidget_NotifyItem : public UUserWidget
{
GENERATED_BODY()
protected:
UPROPERTY(meta=(BindWidgetOptional))
TObjectPtr<UTextBlock> MessageText;
UPROPERTY(meta=(BindWidgetOptional))
TObjectPtr<UImage> IconImage;
/** 上浮距离(像素) */
UPROPERTY(EditDefaultsOnly, Category="PHY|UI|Anim")
float FloatDistance = 18.0f;
/** 出现动画时长(秒) */
UPROPERTY(EditDefaultsOnly, Category="PHY|UI|Anim")
float AppearDuration = 0.12f;
/** 淡出动画时长(秒) */
UPROPERTY(EditDefaultsOnly, Category="PHY|UI|Anim")
float FadeOutDuration = 0.20f;
/** 出现时的起始缩放1.0 为不缩放),建议 0.96~1.0 */
UPROPERTY(EditDefaultsOnly, Category="PHY|UI|Anim")
float AppearStartScale = 0.98f;
/** 淡出阶段额外上浮距离(像素) */
UPROPERTY(EditDefaultsOnly, Category="PHY|UI|Anim")
float FadeOutExtraFloat = 6.0f;
bool bAnimating = false;
bool bFadingOut = false;
float AnimTime = 0.f;
virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;
public:
UFUNCTION(BlueprintCallable)
void SetMessage(const FText& InText);
UFUNCTION(BlueprintCallable)
void SetColor(const FLinearColor& InColor);
UFUNCTION(BlueprintCallable)
void SetIcon(UTexture2D* InTexture);
UFUNCTION(BlueprintCallable)
void SetupNotify(const FText& InText, const FLinearColor& InColor, UTexture2D* InIcon);
/** 播放出现动画(上浮+从透明到不透明) */
UFUNCTION(BlueprintCallable)
void PlayAppearAnim();
/** 播放淡出动画(淡出后自动移除由容器负责) */
UFUNCTION(BlueprintCallable)
void PlayExitAnim();
UFUNCTION(BlueprintPure)
float GetFadeOutDuration() const { return FadeOutDuration; }
};