This commit is contained in:
2026-05-30 09:16:35 +07:00
parent 2f87ce19a7
commit 1c0ee6efb7
4001 changed files with 3363438 additions and 1738 deletions

View File

@@ -0,0 +1,40 @@
using UnityEngine;
namespace Invector.vItemManager
{
[vClassHeader("Add Item By ID", "This is a simple example on how to add items using script", openClose = false)]
public class vAddItemByID : vMonoBehaviour
{
public int id, amount;
public bool addToEquipArea=true;
[vHideInInspector("addToEquipArea")]
public bool autoEquip;
public bool destroyAfter;
[vHideInInspector("addToEquipArea")]
public int indexOfEquipArea;
/// <summary>
/// Simple example on how to add one or more items into the inventory using code
/// You can also auto equip the item if it's a MeleeWeapon Type
/// </summary>
/// <param name="other"></param>
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
var itemManager = other.gameObject.GetComponent<vItemManager>();
if (itemManager)
{
var reference = new ItemReference(id);
reference.amount = amount;
reference.addToEquipArea = addToEquipArea;
reference.autoEquip = autoEquip;
reference.indexArea = indexOfEquipArea;
itemManager.CollectItem(reference,textDelay:2f,ignoreItemAnimation:false);
if (destroyAfter) Destroy(gameObject);
}
}
}
}
}