80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
using System;
|
|
using MotionFramework;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace ToolsPack
|
|
{
|
|
public class ToolsPackWindowItemBtComponent : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
|
{
|
|
[SerializeField] private RawImage ico;
|
|
[SerializeField] private GameObject closeBt;
|
|
[SerializeField] private string btName;
|
|
[SerializeField] private int index;
|
|
[SerializeField] private Text btNameText;
|
|
[SerializeField] private ModelTypeEnum _modelTypeEnum;
|
|
[SerializeField] private GameObject selectImage;
|
|
|
|
private void Start()
|
|
{
|
|
closeBt.GetComponent<Button>().onClick.AddListener(delegate
|
|
{
|
|
GameObject toolsGame = MotionEngine.GetModule<ToolsPackManager>().GetToolsPack(btName, index);
|
|
toolsGame.SetActive(true);
|
|
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPack(btName, index);
|
|
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPackWindowItemBts(btName, index);
|
|
});
|
|
|
|
|
|
this.GetComponent<Button>().onClick.AddListener(delegate
|
|
{
|
|
MotionEngine.GetModule<ToolsPackManager>().OnTriggerStringEvent(btName);
|
|
switch (_modelTypeEnum)
|
|
{
|
|
case ModelTypeEnum.工具:
|
|
break;
|
|
case ModelTypeEnum.设备:
|
|
MotionEngine.GetModule<ToolsPackManager>().DeleteStringToolsPack(btName, index);
|
|
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPackWindowItemBts(btName, index);
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
|
|
public void Init(string gName, string btName, int index, ModelTypeEnum modelTypeEnum)
|
|
{
|
|
btNameText.text = gName;
|
|
this.btName = btName;
|
|
this.index = index;
|
|
_modelTypeEnum = modelTypeEnum;
|
|
ico.texture = MotionEngine.GetModule<ToolsPackManager>().GetToolsPackWindowBtImage(gName);
|
|
if (MotionEngine.GetModule<ToolsPackManager>().GetToolsPackScene() == ToolsPackScene.工具间)
|
|
{
|
|
closeBt.SetActive(true);
|
|
}
|
|
// else
|
|
// {
|
|
// closeBt.SetActive(false);
|
|
// }
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
btNameText.gameObject.SetActive(true);
|
|
selectImage.gameObject.SetActive(true);
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
btNameText.gameObject.SetActive(false);
|
|
selectImage.gameObject.SetActive(false);
|
|
}
|
|
|
|
public int GetIndex()
|
|
{
|
|
return index;
|
|
}
|
|
}
|
|
} |