zoukankan      html  css  js  c++  java
  • Unity3D 判断鼠标是否按在UGUI上

    判断鼠标是否点击在UGUI上

    #if UNITY_ANDROID && !UNITY_EDITOR
    #define ANDROID
    #endif
     
     
    #if UNITY_IPHONE && !UNITY_EDITOR
    #define IPHONE
    #endif
     
     
     
    using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;
    using UnityEngine.EventSystems;
    public class NewBehaviourScript : MonoBehaviour {
     
        // Use this for initialization
        void Start () {
        
        }
        
     
        void Update()
        {
            if (Input.GetMouseButtonDown(0)||(Input.touchCount >0 && Input.GetTouch(0).phase == TouchPhase.Began))
            {
    #if IPHONE || ANDROID
                if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
    #else
                if (EventSystem.current.IsPointerOverGameObject())
    #endif
                    Debug.Log("当前触摸在UI上");
                
                else 
                    Debug.Log("当前没有触摸在UI上");
            }
        }
    }

    方法来自:http://www.xuanyusong.com/archives/3327

  • 相关阅读:
    Rate Control Mode
    帝国的困境:80-20法则
    ARM NEON 64bit 查找表替换
    Video Brightness Enhancement
    HDR(High Dynamic Range)
    C++ C++
    Machine Learning
    图像处理
    Facial landmark detection
    git
  • 原文地址:https://www.cnblogs.com/sunxun/p/5828009.html
Copyright © 2011-2022 走看看