Hi all total noob here keen to learn more.
I have followed the moralis skyrim shop demo and setup playfab for my store. I am now looking to go a step further and in one of my stores (Item Shop) I have a button on a canvas named (trade Button), I am trying when the button is pressed to call the subtract api call to playfab and have 1 token removed from the player.
I have tried numerous ways. Ideally it would be in the script below but if easier then can be in an empty object as its own script and dragged into the onclick event on the button itself.
Can someone help with the code? - Thank you
using System; using TMPro; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; using PlayFab; using PlayFab.ClientModels; namespace Web3_Skyrim { public class ItemShop : ShopBase { public static Action<int, int> OnTradeExecuted; private PlayFabVirtualCurrency _playFabVirtualCurrency; [Header("Header UI")] [SerializeField] private TextMeshProUGUI crystalBalanceLabel; private int _currentCrystalBalance; #region UNITY_LIFECYCLE private void Awake() { title.text = "ItemShop"; } protected override void OnEnable() { base.OnEnable(); ResetData(); // First we create a new instance and we subscribe to the needed event _playFabVirtualCurrency = new PlayFabVirtualCurrency(); _playFabVirtualCurrency.OnGetBalanceSuccess += OnGetBalanceSuccessHandler; // Now we call the GetBalance function. We will get the balance on the event that we just subscribed _playFabVirtualCurrency.GetBalance(); } private void OnDisable() { ResetData(); _playFabVirtualCurrency.OnGetBalanceSuccess -= OnGetBalanceSuccessHandler; } #endregion public void OnTradeButtonPressed() { } #region EVENT_HANDLERS private void OnGetBalanceSuccessHandler(int currencyBalance) { _currentCrystalBalance = currencyBalance; crystalBalanceLabel.text = _currentCrystalBalance.ToString(); } private void ResetData() { } } } #endregion