61 lines
1.9 KiB
C#
61 lines
1.9 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;
|
|
|
|
|
|
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);
|
|
});
|
|
}
|
|
|
|
public void Init(string gName, string btName,int index)
|
|
{
|
|
btNameText.text = gName;
|
|
this.btName = btName;
|
|
this.index = index;
|
|
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);
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
btNameText.gameObject.SetActive(false);
|
|
}
|
|
|
|
public int GetIndex()
|
|
{
|
|
return index;
|
|
}
|
|
}
|
|
} |