1. 程式人生 > >NGUI中 鼠標劃出屏幕後,停止對 UIDragScrollView 的 press

NGUI中 鼠標劃出屏幕後,停止對 UIDragScrollView 的 press

form style sta orm void win iou check drag

using UnityEngine;

/// <summary>
/// NGUI中 鼠標劃出屏幕後,停止對 UIDragScrollView 的 press
/// </summary>
public class CheckIsDragOverUI : MonoBehaviour
{
    UIDragScrollView dragSV = null;

    void Start()
    {
        if (null == dragSV)
            dragSV = gameObject.GetComponent<UIDragScrollView>();
    }

    
bool isPressing = false; void Update() { if (RuntimePlatform.WindowsEditor == Application.platform || RuntimePlatform.WindowsPlayer == Application.platform) { if (isPressing) { if (null != dragSV && null != dragSV.scrollView) {
//判斷鼠標是否劃出了屏幕 Vector3 mousePostion = Input.mousePosition; GameObject hoverobject = UICamera.Raycast(mousePostion) ? UICamera.lastHit.collider.gameObject : null; if (null == hoverobject) { isPressing
= false; dragSV.scrollView.Press(false); } } } } } void OnPress(bool pressed) { isPressing = pressed; } }

NGUI中 鼠標劃出屏幕後,停止對 UIDragScrollView 的 press