KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
UTabIndicator.cpp
이 파일의 문서화 페이지로 가기
1// Copyright (c) 2025 Doppleddiggong. All rights reserved. Unauthorized copying, modification, or distribution of this file, via any medium is strictly prohibited. Proprietary and confidential.
2
3#include "UTabIndicator.h"
4#include "Components/CanvasPanelSlot.h"
5#include "TimerManager.h"
6#include "Components/PanelWidget.h"
7
9{
10 Super::NativeDestruct();
11
12 // 타이머 정리
13 if (GetWorld())
14 {
15 GetWorld()->GetTimerManager().ClearTimer(AnimTimerHandle);
16 }
17}
18
19void UTabIndicator::MoveTo(FVector2D InTargetPosition, bool InAnimate)
20{
21 UCanvasPanelSlot* CanvasSlot = GetCanvasSlot();
22 if (!CanvasSlot)
23 return;
24
25 // 애니메이션 없이 즉시 이동
26 if (!InAnimate || AnimationSpeed <= 0.0f)
27 {
28 CanvasSlot->SetPosition(InTargetPosition);
29 bIsAnimating = false;
30
31 // 이동 완료 이벤트 발생
32 OnMoveCompleted.Broadcast();
33 return;
34 }
35
36 // 애니메이션으로 이동
37 AnimStartPosition = CanvasSlot->GetPosition();
38 AnimTargetPosition = InTargetPosition;
39 AnimElapsedTime = 0.0f;
40 bIsAnimating = true;
41
42 // 타이머 시작 (기존 타이머가 있다면 제거)
43 if (GetWorld())
44 {
45 GetWorld()->GetTimerManager().ClearTimer(AnimTimerHandle);
46 GetWorld()->GetTimerManager().SetTimer(
48 this,
50 0.016f, // ~60 FPS
51 true
52 );
53 }
54}
55
57{
58 AnimationSpeed = FMath::Max(0.01f, Speed);
59}
60
62{
63 // Canvas Slot 유효성 검사
64 UCanvasPanelSlot* CanvasSlot = GetCanvasSlot();
65 if (!CanvasSlot)
66 {
67 if (GetWorld())
68 GetWorld()->GetTimerManager().ClearTimer(AnimTimerHandle);
69
70 bIsAnimating = false;
71 return;
72 }
73
74 // 애니메이션 진행
75 AnimElapsedTime += 0.016f; // ~60 FPS 기준
76 const float Alpha = FMath::Clamp(AnimElapsedTime / AnimationSpeed, 0.0f, 1.0f);
77
78 // Lerp를 사용한 부드러운 이동
79 FVector2D CurPosition = FMath::Lerp(AnimStartPosition, AnimTargetPosition, Alpha);
80 CanvasSlot->SetPosition(CurPosition);
81
82 // 애니메이션 완료 확인
83 if (Alpha >= 1.0f)
84 {
85 // 타이머 정지
86 if (GetWorld())
87 {
88 GetWorld()->GetTimerManager().ClearTimer(AnimTimerHandle);
89 }
90
91 bIsAnimating = false;
92
93 // 이동 완료 이벤트 발생
94 OnMoveCompleted.Broadcast();
95 }
96}
97
98UCanvasPanelSlot* UTabIndicator::GetCanvasSlot() const
99{
100 return Cast<UCanvasPanelSlot>(Slot);
101}
void SetAnimationSpeed(float Speed)
애니메이션 속도를 설정합니다.
FVector2D AnimStartPosition
애니메이션 시작 위치
float AnimationSpeed
애니메이션 속도 (초 단위)
FVector2D AnimTargetPosition
애니메이션 목표 위치
FOnMoveCompleted OnMoveCompleted
이동 애니메이션이 완료되었을 때 발생하는 이벤트
virtual void NativeDestruct() override
FTimerHandle AnimTimerHandle
애니메이션을 위한 타이머 핸들
void MoveTo(FVector2D InTargetPosition, bool InAnimate=true)
목표 위치로 이동합니다.
float AnimElapsedTime
애니메이션 진행 시간
void TickAnimation()
애니메이션을 위한 Tick 함수
bool bIsAnimating
애니메이션 진행 중 여부
class UCanvasPanelSlot * GetCanvasSlot() const
현재 위젯의 CanvasPanelSlot을 가져옵니다.