small_slot.cs
990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; // Image 같은 애들 쓸수있게 해줌.
public class small_slot : MonoBehaviour
{
public Image icon;
public Text title; //name + num
public Text desc;
public Button removeButton;
Item item; // 현재 슬롯에 있는 아이템
public GameObject small_inventory_ui;
//그냥 UI뿌려주는 역할도 하고
public void AddItemtoSlot(Item newitem)
{
item = newitem;
icon.sprite = item.itemIcon;
title.text = item.itemName + " x " + item.itemnum + "개";
desc.text = item.itemDes;
icon.enabled = true;
title.enabled = true;
desc.enabled = true;
removeButton.interactable = true;
}
// 버튼 눌리면 처리되는 역할도함
public void OnButton_RemoveItem()
{
small_inventory_ui.GetComponent<small_inventory_UI>().OnButton_RemoveItem(item);
}
}