82 lines
2.2 KiB
C#
82 lines
2.2 KiB
C#
using HighlightPlus;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
/// <summary>
|
|
/// 工具或者材料基类,此脚本必须挂在工具或者材料上
|
|
/// </summary>
|
|
public abstract class BaseToolOrDevice : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 工具Id
|
|
/// </summary>
|
|
public int toolId;
|
|
public string toolName;
|
|
/// <summary>
|
|
/// 工器具类型 工具/材质/设备
|
|
/// </summary>
|
|
public E_ToolOrDeviceOrMaterials toolOrDeviceOrMaterial;
|
|
public HighlightEffect _highlight;
|
|
public bool IsClick = true;
|
|
private void Start()
|
|
{
|
|
_highlight = GetComponentInChildren<HighlightEffect>();
|
|
}
|
|
|
|
[ContextMenu("GetInfo")]
|
|
public void GetInfo()
|
|
{
|
|
//TODO:后续 根据英文名称去获取ID 中文名 和其它
|
|
}
|
|
|
|
private void OnMouseEnter()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType!= E_SceneType.ToolRoom) return;
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
OnEnter();
|
|
//TODO: 这里写提示打开的代码
|
|
UIManager.Instance.ShowPanel<ItemTips>(E_UI_Layer.System, (panel) =>
|
|
{
|
|
panel.Init(gameObject.name);
|
|
GetComponentInChildren<TextMeshProUGUI>().text = gameObject.name;
|
|
transform.position = Input.mousePosition + new Vector3(10, 10, 0);
|
|
}); //提示面板
|
|
}
|
|
|
|
private void OnMouseDown()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType!= E_SceneType.ToolRoom) return;
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
OnDown();
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
private void OnMouseExit()
|
|
{
|
|
UIManager.Instance.HidePanel<ItemTips>();//提示面板
|
|
//TODO: 这里写提示关闭的代码
|
|
if (GameManager.RunModelMgr.SceneType!= E_SceneType.ToolRoom) return;
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
OnExit();
|
|
}
|
|
|
|
|
|
public virtual void OnEnter()
|
|
{
|
|
Debug.Log("进入");
|
|
}
|
|
|
|
public virtual void OnDown()
|
|
{
|
|
Debug.Log("点击");
|
|
}
|
|
|
|
public virtual void OnExit()
|
|
{
|
|
Debug.Log("离开");
|
|
}
|
|
} |