To create a vendor, add the “Vendor.cs” script to a game object.
- Vendor Name: Assign a unique name to each vendor.
- Minimum distance: The minimum distance between the player and vendor object needed to display the vendor UI panel.
- For sale: This array golds all the items for sale, to add an item for sale drag and drop it in this list. It’s recommended that you make the item object inactive before adding to this list so the player can’t be able to pick it up.
- Accepted Items: A list of items names. If the item to sell name doesn’t belong to this list, the vendor won’t accept to buy this item and will send it back to the player’s inventory.
- Panel: Drag and drop the object that contains the “VendorUI.cs” component in this field.
- Audio Clips: Drag and drop audio clips that will be played when the vendor window is shown or hidden, an item is sold or when the player attempts to purchase an item that he can’t afford.