Commit 689e0ad5 authored by 杨泽宇's avatar 杨泽宇

更新

parent df3e73c0
This diff is collapsed.
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;
}
}
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