forked from zxl/LaboratoryProtection
38 lines
905 B
C#
38 lines
905 B
C#
|
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}");
|
|||
|
}
|
|||
|
|
|||
|
#if UNITY_EDITOR
|
|||
|
[Button]
|
|||
|
void Add()
|
|||
|
{
|
|||
|
var component = gameObject.GetOrAddComponent<EventTrigger>();
|
|||
|
// component.OnPointerClick();
|
|||
|
}
|
|||
|
#endif
|
|||
|
public void OnPointerClick(PointerEventData eventData)
|
|||
|
{
|
|||
|
Clicked();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|