You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
61 lines
1.3 KiB
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class SelctedItem : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
public SelctedGroup selctedGroup;
|
|
public int ItemIndex;
|
|
[SerializeField]
|
|
public bool isOpen = false;
|
|
|
|
|
|
public void Init()
|
|
{
|
|
switch (ItemIndex)
|
|
{
|
|
case 1://注入器
|
|
this.GetComponent<Image>().sprite = Resources.Load<Sprite>("image/yuankong");
|
|
break;
|
|
case 2:
|
|
this.GetComponent<Image>().sprite = Resources.Load<Sprite>("image/baibang");
|
|
break;
|
|
case 3:
|
|
this.GetComponent<Image>().sprite = Resources.Load<Sprite>("image/baibang");
|
|
break;
|
|
case 4://设备
|
|
this.GetComponent<Image>().sprite = Resources.Load<Sprite>("image/yuankong");
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
|
|
isOpen = !isOpen;
|
|
if (isOpen)
|
|
{
|
|
selctedGroup.ShowItemList(ItemIndex);
|
|
selctedGroup.CurrentItem = this;
|
|
}
|
|
else
|
|
{
|
|
selctedGroup.ResetItemList();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
if (selctedGroup.CurrentItem != this)
|
|
{
|
|
isOpen = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
|