您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
18 行
440 B
18 行
440 B
using UnityEngine;
|
|
|
|
// Created with collaboration from:
|
|
// https://forum.unity.com/threads/inventory-system.980646/
|
|
public class InventoryController : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Inventory _inventory = default;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.TryGetComponent<ItemInstance>(out ItemInstance itemInstance))
|
|
{
|
|
_inventory.Add(itemInstance.Item);
|
|
Destroy(itemInstance.gameObject);
|
|
}
|
|
}
|
|
}
|