Commit 6b216595 authored by 张英美's avatar 张英美

Merge branch 'main' of git@gitlab.sd-zeus.com:yangzeyu/ShunZhiMazeVR.git

parents 88d764a4 10bbe63d
This diff is collapsed.
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 滑动验证
/// </summary>
public class SlidingVerification : MonoBehaviour public class SlidingVerification : MonoBehaviour
{ {
// Start is called before the first frame update [Tooltip("滑动条")]
void Start() 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;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment