Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
顺
顺职VR迷宫游戏教学
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨泽宇
顺职VR迷宫游戏教学
Commits
4c75d371
Commit
4c75d371
authored
Mar 01, 2024
by
杨泽宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新迷宫第一层
parent
f2bfc70a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
3190 additions
and
599 deletions
+3190
-599
1_Maze1.unity
Assets/_Scenes/1_Maze1.unity
+2895
-596
GrabRayController.cs
Assets/_Scripts/GrabRayController.cs
+1
-1
OperationManager.cs
Assets/_Scripts/OperationManager.cs
+50
-0
OperationManager.cs.meta
Assets/_Scripts/OperationManager.cs.meta
+11
-0
OperationSettings.cs
Assets/_Scripts/OperationSettings.cs
+21
-0
OperationSettings.cs.meta
Assets/_Scripts/OperationSettings.cs.meta
+11
-0
XRControllerManager.cs
Assets/_Scripts/XRControllerManager.cs
+188
-0
XRControllerManager.cs.meta
Assets/_Scripts/XRControllerManager.cs.meta
+11
-0
Minimap.renderTexture
Assets/_美术资源/3_纹理/Minimap.renderTexture
+2
-2
No files found.
Assets/_Scenes/1_Maze1.unity
View file @
4c75d371
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Assets/_Scripts/GrabRayController.cs
View file @
4c75d371
...
...
@@ -43,7 +43,7 @@ public class GrabRayController : MonoBehaviour
EnableAction
(
teleportActivateReference
);
EnableAction
(
moveReference
);
EnableAction
(
turnReference
);
DisableAction
(
rotateAnchorReference
);
//
DisableAction(rotateAnchorReference);
DisableAction
(
translateAnchorReference
);
}
...
...
Assets/_Scripts/OperationManager.cs
0 → 100644
View file @
4c75d371
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.XR.Interaction.Toolkit
;
/// <summary>
/// 操作管理器
/// </summary>
public
class
OperationManager
:
MonoBehaviour
{
[
SerializeField
]
[
Tooltip
(
"惯用手是否是右手(默认右手为惯用手)"
)]
private
bool
IsRight
=
true
;
[
SerializeField
]
private
XRControllerManager
LeftHandManager
;
[
SerializeField
]
private
XRControllerManager
RightHandManager
;
[
SerializeField
]
private
ActionBasedSnapTurnProvider
snapTurnProvider
;
[
SerializeField
]
private
ActionBasedContinuousTurnProvider
smoothTurnProvider
;
[
Tooltip
(
"惯用手"
)]
private
XRControllerManager
Handedness
;
/// <summary>
/// 设置惯用手
/// </summary>
public
void
SetHandedness
(
bool
RightHand
)
{
Handedness
=
RightHand
?
RightHandManager
:
LeftHandManager
;
Handedness
.
SetHandedness
();
}
public
void
SetTurnStyle
(
bool
SmoothTurnEnabled
)
{
Handedness
.
smoothTurnEnabled
=
SmoothTurnEnabled
;
}
public
void
SetMoveScheme
(
bool
SmoothMotionEnabled
)
{
Handedness
.
smoothMotionEnabled
=
SmoothMotionEnabled
;
}
}
Assets/_Scripts/OperationManager.cs.meta
0 → 100644
View file @
4c75d371
fileFormatVersion: 2
guid: 7bebc863f82f009409f034494e2f870e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/_Scripts/OperationSettings.cs
0 → 100644
View file @
4c75d371
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
/// <summary>
/// 操作设置
/// </summary>
public
class
OperationSettings
:
MonoBehaviour
{
// Start is called before the first frame update
void
Start
()
{
}
// Update is called once per frame
void
Update
()
{
}
}
Assets/_Scripts/OperationSettings.cs.meta
0 → 100644
View file @
4c75d371
fileFormatVersion: 2
guid: 969b4a0716e4c4840b61d674bee89b00
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/_Scripts/XRControllerManager.cs
0 → 100644
View file @
4c75d371
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.InputSystem
;
using
UnityEngine.XR.Interaction.Toolkit
;
public
class
XRControllerManager
:
MonoBehaviour
{
[
Space
]
[
Header
(
"交互程序"
)]
[
SerializeField
]
private
XRInteractionGroup
m_ManipulationInteractionGroup
;
[
SerializeField
]
[
Tooltip
(
"抓取物体的射线"
)]
private
XRRayInteractor
grabRayInteractor
;
[
SerializeField
]
[
Tooltip
(
"抓取物体"
)]
private
XRDirectInteractor
grabDirectInteractor
;
[
SerializeField
]
[
Tooltip
(
"抓取时候的判断"
)]
private
GrabRayController
grabRayController
;
[
Space
]
[
Header
(
"Actions"
)]
[
SerializeField
]
[
Tooltip
(
"旋转"
)]
private
InputActionReference
turnReference
;
[
SerializeField
]
[
Tooltip
(
"一定角度旋转"
)]
private
InputActionReference
SnapTurnReference
;
[
SerializeField
]
[
Tooltip
(
"摇杆移动"
)]
private
InputActionReference
MoveReference
;
[
SerializeField
]
[
Tooltip
(
"传送"
)]
private
InputActionReference
TeleportModeActivateReference
;
[
SerializeField
]
private
InputActionReference
TeleportModeCancelReference
;
[
SerializeField
]
public
InputActionReference
rotateAnchorReference
;
[
SerializeField
]
public
InputActionReference
translateAnchorReference
;
[
Space
]
[
Header
(
"设置"
)]
[
SerializeField
]
[
Tooltip
(
"如果为true,将启用连续移动。如果为false,将启用传送。"
)]
private
bool
SmoothMotionEnabled
;
[
SerializeField
]
[
Tooltip
(
"如果为true,将启用连续转弯。如果为false,将启用快速转弯。"
)]
private
bool
SmoothTurnEnabled
;
[
Tooltip
(
"是否是惯用手"
)]
private
bool
isHandedness
=
false
;
private
void
Start
()
{
DisableLocomotionActions
();
grabRayInteractor
.
selectEntered
.
AddListener
(
OnEnterGrab
);
grabRayInteractor
.
selectExited
.
AddListener
(
OnExitGrab
);
}
private
void
OnDestroy
()
{
grabRayInteractor
.
selectEntered
.
RemoveListener
(
OnEnterGrab
);
grabRayInteractor
.
selectExited
.
RemoveListener
(
OnExitGrab
);
}
private
void
OnEnterGrab
(
SelectEnterEventArgs
arg
)
{
if
(
isHandedness
==
true
)
{
DisableLocomotionActions
();
EnableAction
(
rotateAnchorReference
);
EnableAction
(
translateAnchorReference
);
}
}
private
void
OnExitGrab
(
SelectExitEventArgs
arg
)
{
if
(
isHandedness
==
true
)
{
DisableAction
(
rotateAnchorReference
);
DisableAction
(
translateAnchorReference
);
UpdateMoveActions
();
UpdateTurnActions
();
}
}
public
void
SetHandedness
()
{
isHandedness
=
true
;
}
public
bool
smoothTurnEnabled
{
get
=>
SmoothTurnEnabled
;
set
{
SmoothTurnEnabled
=
value
;
UpdateTurnActions
();
}
}
public
bool
smoothMotionEnabled
{
get
=>
SmoothMotionEnabled
;
set
{
SmoothMotionEnabled
=
value
;
UpdateMoveActions
();
}
}
private
void
UpdateTurnActions
()
{
SetEnabled
(
turnReference
,
SmoothTurnEnabled
);
SetEnabled
(
SnapTurnReference
,
!
SmoothTurnEnabled
);
}
private
void
UpdateMoveActions
()
{
SetEnabled
(
MoveReference
,
SmoothMotionEnabled
);
SetEnabled
(
TeleportModeActivateReference
,
!
SmoothMotionEnabled
);
SetEnabled
(
TeleportModeCancelReference
,
!
SmoothMotionEnabled
);
}
private
void
DisableLocomotionActions
()
{
DisableAction
(
turnReference
);
DisableAction
(
SnapTurnReference
);
DisableAction
(
MoveReference
);
DisableAction
(
TeleportModeActivateReference
);
DisableAction
(
TeleportModeCancelReference
);
}
/// <summary>
/// 设置Action的打开和关闭
/// </summary>
/// <param name="actionReference"></param>
/// <param name="enabled"></param>
private
void
SetEnabled
(
InputActionReference
actionReference
,
bool
enabled
)
{
if
(
enabled
)
EnableAction
(
actionReference
);
else
DisableAction
(
actionReference
);
}
/// <summary>
/// 打开Action
/// </summary>
/// <param name="actionReference"></param>
private
void
EnableAction
(
InputActionReference
actionReference
)
{
var
action
=
GetInputAction
(
actionReference
);
if
(
action
!=
null
&&
!
action
.
enabled
)
action
.
Enable
();
}
/// <summary>
/// 关闭Action
/// </summary>
/// <param name="actionReference"></param>
private
void
DisableAction
(
InputActionReference
actionReference
)
{
var
action
=
GetInputAction
(
actionReference
);
if
(
action
!=
null
&&
action
.
enabled
)
action
.
Disable
();
}
/// <summary>
/// 获取Action
/// </summary>
/// <param name="actionReference"></param>
/// <returns></returns>
private
InputAction
GetInputAction
(
InputActionReference
actionReference
)
{
return
actionReference
!=
null
?
actionReference
.
action
:
null
;
}
}
Assets/_Scripts/XRControllerManager.cs.meta
0 → 100644
View file @
4c75d371
fileFormatVersion: 2
guid: b6169cac973668d408b6d8fa1d60f3ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/_美术资源/3_纹理/Minimap.renderTexture
View file @
4c75d371
...
...
@@ -14,8 +14,8 @@ RenderTexture:
m_DownscaleFallback
:
0
m_IsAlphaChannelOptional
:
0
serializedVersion
:
5
m_Width
:
6
00
m_Height
:
6
00
m_Width
:
10
00
m_Height
:
10
00
m_AntiAliasing
:
1
m_MipCount
:
-1
m_DepthStencilFormat
:
94
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment