Version: 5.4
public bool IsPointerOverGameObject (int pointerId);

パラメーター

pointerId ポインタ ID

説明

ゲームオブジェクト上をポインターが通過するとエベントシステムによってコントロールされる

モジュールがポインタベースの場合、ポインタが EventSystem オブジェクト上にあるとき、true を返すようにオーバーライドします。

using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

public class example : MonoBehaviour {

void Update () { // Check if the left mouse button was clicked if(Input.GetMouseButtonDown(0)) { // Check if the mouse was clicked over a UI element if(!EventSystem.current.IsPointerOverGameObject()) { Debug.Log("Did not Click on the UI"); } } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961