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
689e0ad5
Commit
689e0ad5
authored
Feb 29, 2024
by
杨泽宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
df3e73c0
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
641 additions
and
16 deletions
+641
-16
2_Maze2.unity
Assets/_Scenes/2_Maze2.unity
+593
-10
SlidingVerification.cs
Assets/_Scripts/SlidingVerification.cs
+48
-6
No files found.
Assets/_Scenes/2_Maze2.unity
View file @
689e0ad5
This diff is collapsed.
Click to expand it.
Assets/_Scripts/SlidingVerification.cs
View file @
689e0ad5
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.UI
;
/// <summary>
/// 滑动验证
/// </summary>
public
class
SlidingVerification
:
MonoBehaviour
{
// Start is called before the first frame update
void
Start
()
[
Tooltip
(
"滑动条"
)]
public
Slider
slider
;
[
Tooltip
(
"验证中心点位置"
)]
public
float
triggerPosition
;
[
Tooltip
(
"验证前后范围"
)]
public
float
triggerThreshold
=
0.5f
;
[
Tooltip
(
"正确反馈UI"
)]
public
GameObject
SuccessUI
;
private
bool
isDragging
=
false
;
private
void
Start
()
{
if
(
slider
==
null
)
{
Debug
.
LogError
(
"没有设置Slider"
);
enabled
=
false
;
}
}
private
void
Update
()
{
// 如果滑动条正在被拖动
if
(
isDragging
)
{
return
;
}
else
{
// 如果滑动条的值在触发位置及其范围内
if
(
slider
.
value
>=
triggerPosition
-
triggerThreshold
&&
slider
.
value
<=
triggerPosition
+
triggerThreshold
)
{
SuccessUI
.
SetActive
(
true
);
}
}
}
//
Update is called once per frame
void
Update
()
//
当开始拖动滑动条时调用
public
void
OnSliderDragStart
()
{
isDragging
=
true
;
}
// 当停止拖动滑动条时调用
public
void
OnSliderDragEnd
()
{
isDragging
=
false
;
}
}
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