|
Post by ammarofficial11 on Oct 29, 2019 11:39:07 GMT
for my mobile game I've create and Unequip button and assign script to it. You can check my video.. the trick is to use vRemoveCurrentItem script.
insert code here public vShooterManager shooter1;
public bool Unequipweapon = false;
public UnityEvent OnTriggerUnEquipEvent;
public GameObject other;
public enum Type
{
UnequipItem,
DestroyItem,
DropItem
}
public Type type = Type.UnequipItem;
[Tooltip("Immediately equip the item ignoring the Equip animation")]
public bool immediate = true;
[Tooltip("Index Area of your Inventory Prefab")]
public int indexOfArea;
//public UnityEvent OnTriggerEnterEvent;
public virtual void UnEquipCurrentWeapon(bool immediate = false)
{
if (Unequipweapon == true)
{
//HideWeapons();
if (other.gameObject.CompareTag("Player"))
{
var itemManager = other.gameObject.GetComponent<vItemManager>();
if (itemManager)
{
if (type == Type.UnequipItem)
itemManager.UnequipCurrentEquipedItem(indexOfArea, immediate);
else if (type == Type.DestroyItem)
itemManager.LeaveCurrentEquipedItem(indexOfArea, immediate);
else
itemManager.DropCurrentEquipedItem(indexOfArea, immediate);
}
OnTriggerUnEquipEvent.Invoke();
}
}
}
]
|
|