36 lines
762 B
C#
36 lines
762 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using System;
|
|
|
|
|
|
public class ActionClickedEvent : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
|
|
public event Action<GameObject> OnItemClicked; // 定义事件,用来被父节点监听
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void ClearListeners()
|
|
{
|
|
OnItemClicked = null;
|
|
}
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
//Debug.Log($"点击了对象: {gameObject.name}");
|
|
|
|
OnItemClicked?.Invoke(gameObject);//触发事件,传回自身参数
|
|
}
|
|
}
|