You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1005 B
50 lines
1005 B
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
namespace Ui.Screens |
|
{ |
|
public class ScreenThreshold : MonoBehaviour |
|
{ |
|
|
|
[SerializeField] private ScrollRect _scrollbar; |
|
|
|
private float _startPosition = float.MinValue; |
|
|
|
private void OnEnable() |
|
{ |
|
if (_scrollbar == null) |
|
return; |
|
_scrollbar.onValueChanged.AddListener(Call); |
|
ScreenContainer.DragEvent += OnDragEvent; |
|
} |
|
|
|
private void OnDisable() |
|
{ |
|
if (_scrollbar == null) |
|
return; |
|
ScreenContainer.DragEvent -= OnDragEvent; |
|
} |
|
|
|
private void Update() |
|
{ |
|
if (Input.GetMouseButtonUp(0)) |
|
{ |
|
_startPosition = float.MinValue; |
|
} |
|
} |
|
|
|
private void Call(Vector2 arg0) |
|
{ |
|
if (_startPosition <= float.MinValue) |
|
_startPosition = Input.mousePosition.y; |
|
|
|
if (_scrollbar.vertical && !ScreenContainer.Hold && Mathf.Abs(Input.mousePosition.y - _startPosition) > 0.05f * Screen.height) |
|
ScreenContainer.Hold = true; |
|
} |
|
|
|
private void OnDragEvent(bool obj) |
|
{ |
|
_scrollbar.vertical = !obj; |
|
} |
|
} |
|
}
|
|
|