Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Widget Interaction Plugin
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LuFG VR VIS
VR-Group
Unreal-Development
Plugins
Widget Interaction Plugin
Commits
6158bebe
Commit
6158bebe
authored
5 years ago
by
Jonathan Wendt
Browse files
Options
Downloads
Patches
Plain Diff
improve setup of widgetinteractioncomponent
parent
1ad51beb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/WidgetInteraction/Private/WidgetInteraction.cpp
+32
-33
32 additions, 33 deletions
Source/WidgetInteraction/Private/WidgetInteraction.cpp
Source/WidgetInteraction/Public/WidgetInteraction.h
+3
-3
3 additions, 3 deletions
Source/WidgetInteraction/Public/WidgetInteraction.h
with
35 additions
and
36 deletions
Source/WidgetInteraction/Private/WidgetInteraction.cpp
+
32
−
33
View file @
6158bebe
...
...
@@ -12,8 +12,7 @@ DEFINE_LOG_CATEGORY(WidgetIntLog);
void
FWidgetInteractionModule
::
StartupModule
()
{
on_world_tick_start_delegate_
.
BindRaw
(
this
,
&
FWidgetInteractionModule
::
OnWorldTickStart
);
FWorldDelegates
::
OnWorldTickStart
.
Add
(
on_world_tick_start_delegate_
);
FWorldDelegates
::
OnWorldPreActorTick
.
AddRaw
(
this
,
&
FWidgetInteractionModule
::
OnWorldPreActorTick
);
}
void
FWidgetInteractionModule
::
ShutdownModule
()
...
...
@@ -21,46 +20,46 @@ void FWidgetInteractionModule::ShutdownModule()
}
void
FWidgetInteractionModule
::
OnWorldTickStart
(
ELevelTick
level_tick
,
float
val
)
{
//since OnWorldTickStart is called independent of the world/level we are in,
//we need to check whether the level changed and, if so, reattach the interaction component
auto
worlds
=
GEngine
->
GetWorldContexts
();
for
(
auto
world_context
:
worlds
)
{
void
FWidgetInteractionModule
::
OnWorldPreActorTick
(
UWorld
*
World
,
ELevelTick
TickType
,
float
DeltaTime
)
{
auto
world
=
world_context
.
World
();
if
(
last_world
==
World
)
return
;
if
(
last_world
==
world
&&
widget_interaction_cmp_
!=
nullptr
)
{
if
(
widget_interaction_cmp_
->
IsValidLowLevel
()
==
true
)
{
continue
;
}
else
{
widget_interaction_cmp_
=
nullptr
;
}
if
(
World
->
GetFirstPlayerController
()
==
nullptr
)
{
UE_LOG
(
WidgetIntLog
,
Error
,
TEXT
(
"No PlayerController available in OnWorldPreActorTick"
));
return
;
}
if
(
world
==
nullptr
)
continue
;
auto
player_controller
=
world
->
GetFirstPlayerController
();
if
(
player_controller
==
nullptr
)
continue
;
auto
vr_pawn
=
dynamic_cast
<
AVirtualRealityPawn
*>
(
player_controller
->
AcknowledgedPawn
);
if
(
vr_pawn
==
nullptr
)
continue
;
APawn
*
Pawn
=
World
->
GetFirstPlayerController
()
->
AcknowledgedPawn
;
if
(
Pawn
==
nullptr
)
{
UE_LOG
(
WidgetIntLog
,
Error
,
TEXT
(
"No Pawn available in OnWorldPreActorTick"
));
return
;
}
CreateWidgetInteraction
(
vr_pawn
->
GetRightHandComponent
(),
vr_pawn
);
last_world
=
world
;
AVirtualRealityPawn
*
VRPawn
=
Cast
<
AVirtualRealityPawn
>
(
Pawn
);
if
(
VRPawn
==
nullptr
)
{
UE_LOG
(
WidgetIntLog
,
Error
,
TEXT
(
"Pawn is not of type AVirtualRealityPawn in OnWorldPreActorTick"
));
return
;
}
CreateWidgetInteraction
(
VRPawn
->
GetRightHandComponent
(),
VRPawn
);
last_world
=
World
;
UE_LOG
(
WidgetIntLog
,
Verbose
,
TEXT
(
"VRInteractionComponent attached to right hand"
));
}
}
UVRWidgetInteractionComponent
*
FWidgetInteractionModule
::
GetWidgetInteractionComponent
()
{
if
(
widget_interaction_cmp_
->
IsValidLowLevel
()
==
true
)
{
return
widget_interaction_cmp_
;
}
else
{
return
nullptr
;
}
}
void
FWidgetInteractionModule
::
CreateWidgetInteraction
(
USceneComponent
*
parent
,
AVirtualRealityPawn
*
outer
)
{
...
...
This diff is collapsed.
Click to expand it.
Source/WidgetInteraction/Public/WidgetInteraction.h
+
3
−
3
View file @
6158bebe
...
...
@@ -5,6 +5,7 @@
#include
"CoreMinimal.h"
#include
"VirtualRealityPawn.h"
#include
"VRWidgetInteractionComponent.h"
#include
"Engine/World.h"
#include
"Modules/ModuleManager.h"
DECLARE_LOG_CATEGORY_EXTERN
(
WidgetIntLog
,
Log
,
All
);
...
...
@@ -17,7 +18,7 @@ public:
virtual
void
StartupModule
()
override
;
virtual
void
ShutdownModule
()
override
;
UFUNCTION
()
void
OnWorld
TickStart
(
ELevelTick
,
float
);
UFUNCTION
()
void
OnWorld
PreActorTick
(
UWorld
*
World
,
ELevelTick
TickType
,
float
DeltaTime
);
UVRWidgetInteractionComponent
*
GetWidgetInteractionComponent
();
...
...
@@ -25,8 +26,7 @@ private:
void
CreateWidgetInteraction
(
USceneComponent
*
parent
,
AVirtualRealityPawn
*
outer
);
private:
TBaseDelegate
<
void
,
ELevelTick
,
float
>
on_world_tick_start_delegate_
;
UVRWidgetInteractionComponent
*
widget_interaction_cmp_
;
UWorld
*
last_world
;
UWorld
*
last_world
=
nullptr
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment