iLMS知識社群歷程檔登入
位置: 黃國哲 > Unity
1100826 背包物品製作Script
by 黃國哲 2021-08-26 14:04:46, 回應(0), 人氣(485)

1.新增物品與屬性設定

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "New Item",menuName = "Inventory/New Item")]
public class item : ScriptableObject
{
    public string itemName;
    public Sprite itemImage;
    public int itemHeld;
    [TextArea]
    public string itemInfo;
}

2.交替按鈕製作

public GameObject myBag ;
bool isOpen;

void OpenMyBag()
{
if (Input.GetKeyDown(KeyCode.O))
{
isOpen = !isOpen ;
myBag.SetActive(isOpen);
}


}

回應