21 : RadialFloatingMesh(nullptr)
22 , RadialArrowMesh(nullptr)
23 , TimelineComponent(nullptr)
26 , CurrentNormalAngleIndex(-1)
27 , CurrentLargeAngleIndex(-1)
28 , PreviousNormalAngleIndex(-1)
29 , PreviousLargeAngleIndex(-1)
30 , AnglePerNormalItem(0.0f)
31 , AnglePerLargeItem(0.0f)
33 , IconRadialDistance(7.0f)
34 , IconRelativeScale(FVector(1.0f / 25.0f))
35 , CurrentPadDirection(FVector2D::ZeroVector)
36 , CurrentArrowRotation(FRotator::ZeroRotator)
37 , WidgetDataTableDefault(nullptr)
38 , WidgetDataTable(nullptr)
40 , CurrentPointedWidgetComponent(nullptr)
41 , CurrentLargePointedWidgetComponent(nullptr)
42 , RotationSpeed(1000.0f)
43 , bAlignToPlayerHead(false)
44 , MaxNumberOfNormalButtons(8)
45 , MaxNumberOfLargeButtons(6)
47 PrimaryActorTick.bCanEverTick =
true;
48 PrimaryActorTick.bStartWithTickEnabled =
false;
51 AActor::SetReplicateMovement(
true);
53 static ConstructorHelpers::FObjectFinder<USoundCue> SelectSoundCueFinder(TEXT(
"SoundCue'/PixoCore/Audio/SFX/PixoVR_UI_Menu_select_Cue.PixoVR_UI_Menu_Select_Cue'"));
56 static ConstructorHelpers::FObjectFinder<USoundCue> HoverSoundCueFinder(TEXT(
"SoundCue'/PixoCore/Audio/SFX/PixoVR_UI_Hover_Cue.PixoVR_UI_Hover_Cue'"));
59 static ConstructorHelpers::FObjectFinder<UStaticMesh> WristMenuMeshFinder(TEXT(
"StaticMesh'/PixoCore/WristMenu/SM_Radial_Disk.SM_Radial_Disk'"));
60 UStaticMesh* WristMenuMesh = WristMenuMeshFinder.Object;
62 static ConstructorHelpers::FObjectFinder<UMaterialInstance> WristMenuMeshMaterialFinder(TEXT(
"MaterialInstanceConstant'/PixoCore/WristMenu/DiscMaterial.DiscMaterial'"));
63 UMaterialInstance* WristMenuMeshMaterial = WristMenuMeshMaterialFinder.Object;
65 static ConstructorHelpers::FObjectFinder<UStaticMesh> WristMenuArrowMeshFinder(TEXT(
"StaticMesh'/PixoCore/WristMenu/SM_Radial_Pointer.SM_Radial_Pointer'"));
66 UStaticMesh* WristMenuArrowMesh = WristMenuArrowMeshFinder.Object;
68 static ConstructorHelpers::FObjectFinder<UMaterial> WristMenuArrowMaterialFinder(TEXT(
"Material'/PixoCore/WristMenu/ArrowMaterial.ArrowMaterial'"));
69 UMaterial* WristMenuArrowMaterial = WristMenuArrowMaterialFinder.Object;
71 static ConstructorHelpers::FClassFinder<UUserWidget> WristMenuWidget(TEXT(
"/PixoCore/WristMenu/PixoVRWristMenuWidget"));
74 static ConstructorHelpers::FClassFinder<UUserWidget> WristMenuTitleWidget(TEXT(
"/PixoCore/WristMenu/PixoVRWristMenuTitleWidget"));
77 SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT(
"WristMenuSceneComponent"));
80 RadialFloatingMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT(
"WristMenuMesh"));
84 RadialFloatingMesh->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
88 RadialArrowMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT(
"WristMenuRadialArrowMesh"));
92 RadialArrowMesh->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
94 AudioComponent = CreateDefaultSubobject<UAudioComponent>(TEXT(
"AudioComponent"));
96 TimelineComponent = CreateDefaultSubobject<UTimelineComponent>(TEXT(
"TimelineComponent"));
100 AActor::SetActorHiddenInGame(
true);
200 const APixoVRCharacter* Character = Cast<APixoVRCharacter>(UGameplayStatics::GetPlayerPawn(
this, 0));
203 const auto PlatformName = UGameplayStatics::GetPlatformName();
207 Rotator = UKismetMathLibrary::FindLookAtRotation(Character->
Head->GetComponentLocation(), RootComponent->GetComponentLocation());
208 Rotator.Add(90.0f, 0.0f, 0.0f);
294 if (
Title !=
nullptr)
296 Title->UnregisterComponent();
297 const FDetachmentTransformRules DetachmentTransformRules(EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative,
true);
298 Title->DetachFromComponent(DetachmentTransformRules);
299 Title->ConditionalBeginDestroy();
305 WidgetComponent->UnregisterComponent();
306 FDetachmentTransformRules DetachmentTransformRules(EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative,
true);
307 WidgetComponent->DetachFromComponent(DetachmentTransformRules);
308 WidgetComponent->ConditionalBeginDestroy();
309 WidgetComponent =
nullptr;
314 WidgetComponent->UnregisterComponent();
315 FDetachmentTransformRules DetachmentTransformRules(EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative,
true);
316 WidgetComponent->DetachFromComponent(DetachmentTransformRules);
317 WidgetComponent->ConditionalBeginDestroy();
318 WidgetComponent =
nullptr;
479 UE_LOG(LogPixoVRWristMenu,
Warning, TEXT(
"Can't create widgets because of some issues with the data table."));
486 Title = NewObject<UWidgetComponent>(
this);
488 const FAttachmentTransformRules TitleAttachmentTransformRules(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative,
true);
490 Title->RegisterComponent();
491 Title->SetCollisionEnabled(ECollisionEnabled::NoCollision);
492 Title->SetGenerateOverlapEvents(
false);
493 Title->SetTwoSided(
true);
494 Title->SetOpacityFromTexture(1.0f);
495 Title->SetBackgroundColor(FLinearColor::Transparent);
496 Title->SetBlendMode(EWidgetBlendMode::Masked);
498 Title->SetRelativeLocation(FVector(0.f, 0.f, 3.f));
500 const FQuat TitleRotationPitch(FVector::RightVector, FMath::DegreesToRadians(90.0f));
501 const FQuat TitleRotationYaw(FVector::UpVector, FMath::DegreesToRadians(180.0f));
502 const FQuat TitleRotationRot = TitleRotationPitch * TitleRotationYaw;
504 Title->SetRelativeRotation(TitleRotationRot);
510 Title->SetWidget(TitleWidget);
513 uint32 WidgetItemPositionIndex = 0;
514 uint32 LargeWidgetItemPositionIndex = 0;
515 float NumberOfNormalButtonItems = 0;
516 float NumberOfLargeButtonItems = 0;
522 ++NumberOfNormalButtonItems;
527 ++NumberOfLargeButtonItems;
533 UE_LOG(LogPixoVRWristMenu,
Warning, TEXT(
"There are too many menu items to fit on the wrist menu."));
540 check(WidgetComponent)
542 FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative,
true);
543 WidgetComponent->AttachToComponent(
RadialFloatingMesh, AttachmentTransformRules, NAME_None);
544 WidgetComponent->RegisterComponent();
545 WidgetComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
546 WidgetComponent->SetGenerateOverlapEvents(
false);
547 WidgetComponent->SetTwoSided(
true);
548 WidgetComponent->SetOpacityFromTexture( 1.0f );
549 WidgetComponent->SetBackgroundColor( FLinearColor::Transparent );
550 WidgetComponent->SetBlendMode( EWidgetBlendMode::Masked );
568 WidgetComponent->SetRelativeLocation(FVector(RadialX, RadialY, 2.5f));
570 FQuat Rot = TitleRotationPitch * TitleRotationYaw;
572 WidgetComponent->SetRelativeRotation(Rot);
581 WidgetComponent->SetWidget(Widget);
587 Widget->
SetButtonAngle((-22.5f * (NumberOfNormalButtonItems - 1)) + (45.0f * WidgetItemPositionIndex));
588 WidgetItemPositionIndex++;
593 Widget->
SetButtonAngle(180.0f+(-30.00f * (NumberOfLargeButtonItems - 1)) + (60.0f * LargeWidgetItemPositionIndex));
595 LargeWidgetItemPositionIndex++;