66 lines
1.4 KiB
C#
66 lines
1.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SlotUI : MonoBehaviour
|
|
{
|
|
[SerializeField] private int index;
|
|
|
|
[SerializeField] private Image icon;
|
|
|
|
[SerializeField] private Button _button;
|
|
|
|
private void Awake()
|
|
{
|
|
_button = GetComponent<Button>();
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_button.onClick.AddListener(ButtonEvent);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_button.onClick.RemoveListener(ButtonEvent);
|
|
}
|
|
|
|
public void ButtonEvent()
|
|
{
|
|
GameSystem.ins.drawingManager.itemsSlot[index] = 0;
|
|
GameSystem.ins.ResetItemPanel();
|
|
}
|
|
public void SaveIndex()
|
|
{
|
|
GameSystem.ins.SaveIndex(index);
|
|
}
|
|
|
|
public void ResetIcon()
|
|
{
|
|
if (GameSystem.ins.drawingManager.itemsSlot[index]!=0)
|
|
{
|
|
icon.gameObject.SetActive(true);
|
|
var data=JsonTab.Instance.tables.Item.Get(GameSystem.ins.drawingManager.itemsSlot[index]);
|
|
icon.sprite = AssetBundleManager.ins.Sprite(data.Icon,AtlasType.ItemIcon);
|
|
}
|
|
else
|
|
{
|
|
icon.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|