Skip to content

Commit eb2cde2

Browse files
mmgaw113ZackAllen
andauthored
Enhancement: Input Manager (#133)
* Input Manager * Update sample code to use input manager * Update Sample levels to have input manager * Update sample_project/Source/sample_project/InputManager.cpp Co-authored-by: Zack Allen <zallen@esri.com> * Update sample_project/Source/sample_project/InputManager.h Co-authored-by: Zack Allen <zallen@esri.com> --------- Co-authored-by: Zack Allen <zallen@esri.com>
1 parent fc5ff99 commit eb2cde2

File tree

21 files changed

+161
-136
lines changed

21 files changed

+161
-136
lines changed
Binary file not shown.
-179 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
307 Bytes
Binary file not shown.
Binary file not shown.
307 Bytes
Binary file not shown.

sample_project/Source/sample_project/Feature Layer/FeatureLayer.cpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#include "ArcGISMapsSDK/Components/ArcGISLocationComponent.h"
2020
#include "ArcGISMapsSDK/Components/ArcGISSurfacePlacementMode.h"
2121
#include "Blueprint/UserWidget.h"
22-
#include "EnhancedInputComponent.h"
2322
#include "FeatureItem.h"
2423
#include "Kismet/GameplayStatics.h"
24+
#include "sample_project/InputManager.h"
2525

2626
AFeatureLayer::AFeatureLayer()
2727
{
@@ -42,19 +42,6 @@ void AFeatureLayer::BeginPlay()
4242
{
4343
Super::BeginPlay();
4444

45-
if (APlayerController* PlayerController = Cast<APlayerController>(GetWorld()->GetFirstPlayerController()))
46-
{
47-
PlayerController->bShowMouseCursor = true;
48-
PlayerController->bEnableClickEvents = true;
49-
50-
SetupPlayerInputComponent(PlayerController->InputComponent);
51-
if (UEnhancedInputLocalPlayerSubsystem* Subsystem =
52-
ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
53-
{
54-
Subsystem->AddMappingContext(MappingContext, 0);
55-
}
56-
}
57-
5845
// Create the UI and add it to the viewport
5946
if (UIWidgetClass)
6047
{
@@ -69,6 +56,13 @@ void AFeatureLayer::BeginPlay()
6956

7057
ArcGISPawn = Cast<AArcGISPawn>(UGameplayStatics::GetPlayerPawn(GetWorld(), 0));
7158

59+
if (!inputManager)
60+
{
61+
return;
62+
}
63+
64+
inputManager->OnInputTrigger.AddDynamic(this, &AFeatureLayer::SelectFeature);
65+
7266
CreateLink();
7367
ProcessWebRequest();
7468
}
@@ -91,6 +85,13 @@ void AFeatureLayer::CreateLink()
9185
bButtonActive = WebLink.Link.EndsWith("outfields=*");
9286
}
9387

88+
void AFeatureLayer::EndPlay(const EEndPlayReason::Type EndPlayReason)
89+
{
90+
Super::EndPlay(EndPlayReason);
91+
92+
inputManager->OnInputTrigger.RemoveDynamic(this, &AFeatureLayer::SelectFeature);
93+
}
94+
9495
//check for errors that could result in a crash or null return
9596
bool AFeatureLayer::HasErrors()
9697
{
@@ -590,11 +591,3 @@ void AFeatureLayer::SpawnFeatures(int Start, int Last)
590591
featureItems.Add(featureItem);
591592
}
592593
}
593-
594-
void AFeatureLayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
595-
{
596-
if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
597-
{
598-
EnhancedInputComponent->BindAction(mousePress, ETriggerEvent::Started, this, &AFeatureLayer::SelectFeature);
599-
}
600-
}

0 commit comments

Comments
 (0)