修改工具包
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
/// <summary>
|
||||
/// 检测鼠标是否在UI上
|
||||
/// </summary>
|
||||
public class PointerOverUIObject : MonoBehaviour {
|
||||
|
||||
private static bool isValid;
|
||||
|
||||
public static bool IsValid => isValid;
|
||||
|
||||
private void Update() {
|
||||
#if UNITY_STANDALONE
|
||||
//电脑平台
|
||||
isValid = EventSystem.current.IsPointerOverGameObject();
|
||||
#elif UNITY_WEBGL
|
||||
//WebGL平台
|
||||
isValid = EventSystem.current.IsPointerOverGameObject();
|
||||
#elif UNITY_ANDROID
|
||||
//安卓平台
|
||||
isValid = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId);
|
||||
#elif UNITY_IOS
|
||||
//苹果平台
|
||||
isValid = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfb91cad7f01d164d9e35b15f9b2c7c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user