I want to purchase Items in the original Custom UI.
image

I would like to be able to purchase items in the Unity Event when the button is clicked.
There doesn't seem to be a buy node in the Event.

Is there any way to achieve this in Event or Script?
  • edited August 2021
    I guess you already have the item (ID) available in your code, since this is a custom UI.

    With the item, you can get the item's price, remove the currency from the player's inventory and add the item:
    ItemShortcut item = new ItemShortcut(id, quantity);
    int price = item.BuyPrice(ORK.Game.ActiveGroup.Leader) * quantity;
    ORK.Game.ActiveGroup.Leader.Inventory.SubMoney(currencyID, price, true, true);
    ORK.Game.ActiveGroup.Leader.Inventory.Add(item, true, true, true);

    id is the ID/index of the item, quantity the quantity you want to purchase.
    currencyID is the ID/index of the currency.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.