66 lines
1.4 KiB
C#
Raw Normal View History

2024-12-25 16:04:25 +08:00
using System;
2024-11-13 16:56:37 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SlotUI : MonoBehaviour
{
[SerializeField] private int index;
[SerializeField] private Image icon;
2024-12-25 16:04:25 +08:00
[SerializeField] private Button _button;
private void Awake()
{
_button = GetComponent<Button>();
}
2024-11-13 16:56:37 +08:00
// Start is called before the first frame update
void Start()
{
}
2024-12-25 16:04:25 +08:00
private void OnEnable()
{
_button.onClick.AddListener(ButtonEvent);
}
2024-11-13 16:56:37 +08:00
// Update is called once per frame
void Update()
{
}
2024-12-25 16:04:25 +08:00
private void OnDisable()
{
_button.onClick.RemoveListener(ButtonEvent);
}
public void ButtonEvent()
{
GameSystem.ins.drawingManager.itemsSlot[index] = 0;
GameSystem.ins.ResetItemPanel();
}
2024-11-13 16:56:37 +08:00
public void SaveIndex()
{
GameSystem.ins.SaveIndex(index);
}
public void ResetIcon()
{
if (GameSystem.ins.drawingManager.itemsSlot[index]!=0)
{
icon.gameObject.SetActive(true);
2024-12-11 13:58:55 +08:00
var data=JsonTab.Instance.tables.Item.Get(GameSystem.ins.drawingManager.itemsSlot[index]);
icon.sprite = AssetBundleManager.ins.Sprite(data.Icon,AtlasType.ItemIcon);
2024-11-13 16:56:37 +08:00
}
else
{
icon.gameObject.SetActive(false);
}
}
}