1
0
Fork 0
LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/ObjectComponent.cs

40 lines
1016 B
C#

using Mono.Event;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI.Extensions;
namespace UnityTest.ZXL
{
public class ObjectComponent : MonoBehaviour, IPointerClickHandler
{
/// <summary>
/// 当前物体的名字(可能存在名字对不上的情况,需要进行深度查找)
/// </summary>
public string objectName;
/// <summary>
/// 描述
/// </summary>
public string desc;
public void Clicked()
{
Debug.Log($"点击了{objectName}");
EventManager.Instance.FireNow(this, new ClickObjectEventArgs(this.gameObject));
}
#if UNITY_EDITOR
[Button]
void Add()
{
var component = gameObject.GetOrAddComponent<EventTrigger>();
// component.OnPointerClick();
}
#endif
public void OnPointerClick(PointerEventData eventData)
{
Clicked();
}
}
}