A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
PixoVRLongHoldComponent.cpp
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
4
6 : NeededTime(0.7f)
7 , MaxShortPressTime(0.2f)
8 , ButtonState (EHoldingState::NONE)
9 , CurrentTime(0.0f)
10
11{
12 PrimaryComponentTick.bCanEverTick = true;
13}
14
15void UPixoVRLongHoldComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
16{
17 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
18
19 switch (ButtonState)
20 {
22 {
23 CurrentTime += DeltaTime;
25 {
27 }
28 }
29 break;
31 {
32 LongHoldReleasedEvent.ExecuteIfBound();
35 }
36 break;
37 default : break;
38 }
39}
40
41void UPixoVRLongHoldComponent::ExecuteLongHold(const FOnLongHoldReleased& LongHoldFunction)
42{
43 LongHoldReleasedEvent = LongHoldFunction;
44 CurrentTime = 0.0f;
46}
47
52
57
59{
60 if (NeededTime > 0)
61 {
62 return CurrentTime / NeededTime;
63 }
64 return 0;
65}
66
71
73{
74 return NeededTime;
75}
EHoldingState
UENUM(BlueprintType)
@ BUTTON_DOWN
Button is pressed down.
@ RELEASED
Button is released.
@ BUTTON_HOLD
Button is being held.
void StopLongHold()
Stops the long hold functionality.
EHoldingState ButtonState
UPROPERTY(BlueprintReadWrite, Category = "PixoVR")
float GetNeededTime() const
Gets the needed time for a successful long hold.
float GetCurrentTime() const
Gets the current time of the long hold.
float NeededTime
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "PixoVR")
float MaxShortPressTime
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "PixoVR")
void ExecuteLongHold(const FOnLongHoldReleased &LongHoldFunction)
Executes the long hold functionality.
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
void IsShortPressValid(bool &IsShortPressValid)
Checks if a short press is valid.
float GetCurrentTimePercentage() const
Gets the current time percentage of the long hold.
float CurrentTime
The current time elapsed during the long hold.
FOnLongHoldReleased LongHoldReleasedEvent
The event to execute when the long hold is released.