Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
AVVR-Unity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GDP Project 4
AVVR-Unity
Commits
f9c66a68
Commit
f9c66a68
authored
5 months ago
by
mhby1g21
Browse files
Options
Downloads
Patches
Plain Diff
added very scuffed and unoptimised checks to disable noVR player movement in menu and vice versa
parent
d831b574
No related branches found
No related tags found
1 merge request
!15
v1.9 released with cubemap texture and transparency slider working
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AVVR/Assets/_Scripts/PlayerController.cs
+29
-4
29 additions, 4 deletions
AVVR/Assets/_Scripts/PlayerController.cs
AVVR/Assets/_Scripts/noVRMenu.cs
+57
-4
57 additions, 4 deletions
AVVR/Assets/_Scripts/noVRMenu.cs
with
86 additions
and
8 deletions
AVVR/Assets/_Scripts/PlayerController.cs
+
29
−
4
View file @
f9c66a68
...
@@ -14,19 +14,24 @@ public class PlayerController : MonoBehaviour
...
@@ -14,19 +14,24 @@ public class PlayerController : MonoBehaviour
private
Camera
playerCamera
;
private
Camera
playerCamera
;
private
float
verticalRotation
=
0f
;
private
float
verticalRotation
=
0f
;
private
Vector3
velocity
;
private
Vector3
velocity
;
private
bool
isEnabled
=
true
;
void
Start
()
void
Start
()
{
{
controller
=
GetComponent
<
CharacterController
>();
controller
=
GetComponent
<
CharacterController
>();
playerCamera
=
GetComponentInChildren
<
Camera
>();
playerCamera
=
GetComponentInChildren
<
Camera
>();
// Lock cursor
// Initial cursor state
Cursor
.
lockState
=
CursorLockMode
.
Locked
;
UpdateCursorState
();
Cursor
.
visible
=
false
;
}
}
void
Update
()
void
Update
()
{
{
if
(!
isEnabled
)
{
return
;
}
// WASD Movement
// WASD Movement
float
moveX
=
Input
.
GetAxis
(
"Horizontal"
);
float
moveX
=
Input
.
GetAxis
(
"Horizontal"
);
float
moveZ
=
Input
.
GetAxis
(
"Vertical"
);
float
moveZ
=
Input
.
GetAxis
(
"Vertical"
);
...
@@ -58,4 +63,24 @@ public class PlayerController : MonoBehaviour
...
@@ -58,4 +63,24 @@ public class PlayerController : MonoBehaviour
velocity
.
y
+=
gravity
*
Time
.
deltaTime
;
velocity
.
y
+=
gravity
*
Time
.
deltaTime
;
controller
.
Move
(
velocity
*
Time
.
deltaTime
);
controller
.
Move
(
velocity
*
Time
.
deltaTime
);
}
}
}
private
void
UpdateCursorState
()
\ No newline at end of file
{
if
(
enabled
)
{
Cursor
.
lockState
=
CursorLockMode
.
Locked
;
Cursor
.
visible
=
false
;
}
}
private
void
OnEnable
()
{
isEnabled
=
true
;
UpdateCursorState
();
}
private
void
OnDisable
()
{
isEnabled
=
false
;
}
}
This diff is collapsed.
Click to expand it.
AVVR/Assets/_Scripts/noVRMenu.cs
+
57
−
4
View file @
f9c66a68
...
@@ -8,6 +8,7 @@ public class NonVRMenu : MonoBehaviour
...
@@ -8,6 +8,7 @@ public class NonVRMenu : MonoBehaviour
{
{
private
bool
isMenuVisible
=
true
;
private
bool
isMenuVisible
=
true
;
private
Canvas
menuCanvas
;
private
Canvas
menuCanvas
;
private
PlayerController
playerController
;
private
AudioClip
musicClip
;
private
AudioClip
musicClip
;
private
AudioClip
singingClip
;
private
AudioClip
singingClip
;
...
@@ -45,6 +46,15 @@ public class NonVRMenu : MonoBehaviour
...
@@ -45,6 +46,15 @@ public class NonVRMenu : MonoBehaviour
menuCanvas
=
GetComponentInChildren
<
Canvas
>();
menuCanvas
=
GetComponentInChildren
<
Canvas
>();
}
}
// Find the PlayerController in the scene
playerController
=
FindObjectOfType
<
PlayerController
>();
if
(
playerController
==
null
)
{
Debug
.
LogWarning
(
"NonVRMenu: PlayerController not found in scene"
);
}
// Set initial state
SetMenuAndPlayerState
(
isMenuVisible
);
// Ensure EventSystem exists
// Ensure EventSystem exists
if
(
FindObjectOfType
<
UnityEngine
.
EventSystems
.
EventSystem
>()
==
null
)
if
(
FindObjectOfType
<
UnityEngine
.
EventSystems
.
EventSystem
>()
==
null
)
{
{
...
@@ -74,16 +84,28 @@ public class NonVRMenu : MonoBehaviour
...
@@ -74,16 +84,28 @@ public class NonVRMenu : MonoBehaviour
private
void
Update
()
private
void
Update
()
{
{
if
(!
isMenuVisible
)
{
// Toggle menu visibility with Tab key
if
(
Input
.
GetKeyDown
(
toggleMenuKey
))
{
ToggleMenuVisibility
();
}
return
;
}
// Toggle menu visibility with Tab key
// Toggle menu visibility with Tab key
if
(
Input
.
GetKeyDown
(
toggleMenuKey
))
if
(
Input
.
GetKeyDown
(
toggleMenuKey
))
{
{
ToggleMenuVisibility
();
ToggleMenuVisibility
();
}
}
//
Toggle audio playback with Space key
//
Only handle other inputs if menu is visible
if
(
Input
.
GetKeyDown
(
toggleAudioKey
)
)
if
(
isMenuVisible
)
{
{
ToggleAudioPlayback
();
if
(
Input
.
GetKeyDown
(
toggleAudioKey
))
{
ToggleAudioPlayback
();
}
}
}
}
}
...
@@ -110,7 +132,8 @@ public class NonVRMenu : MonoBehaviour
...
@@ -110,7 +132,8 @@ public class NonVRMenu : MonoBehaviour
private
void
ToggleMenuVisibility
()
private
void
ToggleMenuVisibility
()
{
{
isMenuVisible
=
!
isMenuVisible
;
isMenuVisible
=
!
isMenuVisible
;
SetMenuAndPlayerState
(
isMenuVisible
);
if
(
menuCanvas
!=
null
)
if
(
menuCanvas
!=
null
)
{
{
menuCanvas
.
enabled
=
isMenuVisible
;
menuCanvas
.
enabled
=
isMenuVisible
;
...
@@ -133,6 +156,36 @@ public class NonVRMenu : MonoBehaviour
...
@@ -133,6 +156,36 @@ public class NonVRMenu : MonoBehaviour
Cursor
.
lockState
=
isMenuVisible
?
CursorLockMode
.
None
:
CursorLockMode
.
Locked
;
Cursor
.
lockState
=
isMenuVisible
?
CursorLockMode
.
None
:
CursorLockMode
.
Locked
;
}
}
private
void
SetMenuAndPlayerState
(
bool
menuVisible
)
{
// Handle menu visibility
if
(
menuCanvas
!=
null
)
{
menuCanvas
.
enabled
=
menuVisible
;
}
else
{
foreach
(
var
canvas
in
GetComponentsInChildren
<
Canvas
>(
true
))
{
canvas
.
enabled
=
menuVisible
;
}
foreach
(
var
renderer
in
GetComponentsInChildren
<
Renderer
>(
true
))
{
renderer
.
enabled
=
menuVisible
;
}
}
// Handle cursor state
Cursor
.
visible
=
menuVisible
;
Cursor
.
lockState
=
menuVisible
?
CursorLockMode
.
None
:
CursorLockMode
.
Locked
;
// Handle player controller state
if
(
playerController
!=
null
)
{
playerController
.
enabled
=
!
menuVisible
;
}
}
private
void
ValidateComponents
()
private
void
ValidateComponents
()
{
{
if
(
volumeSlider
==
null
)
Debug
.
LogError
(
"NonVRMenu: Volume Slider not assigned"
);
if
(
volumeSlider
==
null
)
Debug
.
LogError
(
"NonVRMenu: Volume Slider not assigned"
);
...
...
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