ソースコード
using FancyScrollView;
using UnityEngine;
using UnityEngine.EventSystems;
namespace Kogane.Internal
{
[DisallowMultipleComponent]
internal sealed class Example :
MonoBehaviour,
IPointerEnterHandler,
IPointerExitHandler
{
[SerializeField] private Scroller m_scroller;
[SerializeField] private float m_scrollSensitivity = 1;
private bool m_isPointerEnter;
<summary>
</summary>
void IPointerEnterHandler.OnPointerEnter( PointerEventData eventData )
{
m_isPointerEnter = true;
}
<summary>
</summary>
void IPointerExitHandler.OnPointerExit( PointerEventData eventData )
{
m_isPointerEnter = false;
}
<summary>
</summary>
private void Update()
{
if ( !m_isPointerEnter ) return;
var delta = Input.mouseScrollDelta.y;
if ( delta == 0 ) return;
m_scroller.Position -= delta * m_scrollSensitivity;
}
}
}
m_scrollSensitivity
の値を増やすとマイスホイールを回した時のスクロール量が増える
- 縦スクロールにのみ対応