/
UxtFarCursorComponent.h
69 lines (50 loc) · 1.95 KB
/
UxtFarCursorComponent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "CoreMinimal.h"
#include "Controls/UxtRingCursorComponent.h"
#include "UxtFarCursorComponent.generated.h"
class UUxtFarPointerComponent;
/**
* When added to an actor with a far pointer this component displays a flat ring cursor at the pointer's hit point oriented
* following the hit normal.
*/
UCLASS(ClassGroup = UXTools, meta=(BlueprintSpawnableComponent))
class UXTOOLS_API UUxtFarCursorComponent : public UUxtRingCursorComponent
{
GENERATED_BODY()
public:
UUxtFarCursorComponent();
/** Distance over the hit surface to place the cursor at. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Far Cursor")
float HoverDistance = 0.5f;
/**
* Cursor radius when idle at 1m from the camera.
* The actual radius will scale with the distance to the camera to keep a constant screen size.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Far Cursor")
float IdleRadius = 0.6f;
/**
* Cursor radius when pressed at 1m from the camera.
* The actual radius will scale with the distance to the camera to keep a constant screen size.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Far Cursor")
float PressedRadius = 0.32f;
protected:
//
// UActorComponent interface
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:
UFUNCTION()
void OnFarPointerEnabled(UUxtFarPointerComponent* FarPointer);
UFUNCTION()
void OnFarPointerDisabled(UUxtFarPointerComponent* FarPointer);
void SetPressed(bool bNewPressed);
/** Far pointer in use. */
TWeakObjectPtr<UUxtFarPointerComponent> FarPointerWeak;
bool bPressed = false;
/** Cached ring thicknes for the idle state. Captured when transitioning to pressed. */
float IdleRingThickness;
};