unity ui穿透点击
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; //Encoding:UTF-8 public class UIPointerEventPenetrate : MonoBehaviour, IPointerClickHandler { List<RaycastResult> results = new List<RaycastResult>(); public void OnPointerClick(PointerEventData eventData) { Debug.Log("=dianji="); Psss(eventData, ExecuteEvents.pointerClickHandler); } public void Psss<T>(PointerEventData data, ExecuteEvents.EventFunction<T> function) where T : IEventSystemHandler { results.Clear(); EventSystem.current.RaycastAll(data, results); GameObject current = data.pointerCurrentRaycast.gameObject; for (int i = 0; i < results.Count; i++) { Debug.Log("=dianji=" + results[i].gameObject); if (current != results[i].gameObject) { if (ExecuteEvents.Execute(results[i].gameObject, data, function)) { break; } } } } }
标签:current,ExecuteEvents,gameObject,results,穿透,unity,ui,using,data From: https://www.cnblogs.com/sanyejun/p/18680842