Hi everyone, I wanted to know if there is a way to add a confirmation popup to prevent misclick on virtual transactions? Thank you in advance. Regards
Hi @Reelsy, That's probably not possible with the current Transactions prefab and component, you could however use our TransactionView component as a jumping off point, copy and paste it into your own class and edit it so that it changes the onclick behavior to showing your own dialog game object, instead of immediately initiating the transaction. (You would also need to duplicate our PurchaseButton component and, if you're using our Store prefab, the StoreView component, but you shouldn't need to make any significant changes in those files, they just wouldn't be able to connect to your custom TransactionView component as is.) You can see this thread for an example of a user who customized our StoreView component: https://forum.unity.com/threads/putting-out-an-item-after-buying-from-store.932874/ It's a good idea though, and I've made note of it on our jira board to look into expanding functionality in this way during future prefab improvement passes.
Hi @Reelsy , I wanted to let you know that we just released Game Foundation preview - 0.8.0 (a release forum post is forthcoming). The release includes a change to the Purchase Button prefab that exposes the onClick method subscription, so you could remove PurchaseButton.Purchase as an onClick listener, and instead put a method of your own that opens a confirmation dialog, and which itself calls PurchaseButton.Purchase. To get this new version of the PurchaseButton you'll have to go to re-import the prefabs via Window > Game Foundation > Import Prefabs and Samples As an example (i.e. unofficial and unsupported) here's the steps and code I used when testing the change: Create a simple ConfirmationDialog prefab (ideally with a purchase and cancel button) To your confirmationDialog prefab add the ConfirmationDialogManager, assign the purchase and cancel on click listeners to the methods in this component. To the PurchaseButton prefab add the ConfirmationDialogLauncher class, set your confirmationdialog prefab to the property in the launcher component. Add a store to your scene. Play scene, make a purchase by clicking PurchaseButton. Should see Confirmation dialog open, and when you select purchase, purchase should be initiated, and when you select cancel, it should close dialog and do nothing else. ConfirmationDialogManager: Code (CSharp): using UnityEngine; using UnityEngine.GameFoundation.Components; public class ConfirmationDialogManager : MonoBehaviour { public PurchaseButton currentPurchaseButton; public void StartPurchase() { if (currentPurchaseButton != null) { Debug.Log("Initiating purchase"); currentPurchaseButton.Purchase(); } Destroy(gameObject); } public void CancelPurchase() { Debug.Log("Cancelling purchase"); Destroy(gameObject); } } ConfirmationDialogLauncher: Code (CSharp): using UnityEngine; using UnityEngine.GameFoundation.Components; public class ConfirmationDialogLauncher : MonoBehaviour { public ConfirmationDialogManager dialogBox; public void ShowDialog() { var currentPurchaseButton = gameObject.GetComponent<PurchaseButton>(); var confirmationDialogManager = Instantiate(dialogBox, FindObjectOfType<Canvas>().rootCanvas.transform); confirmationDialogManager.currentPurchaseButton = currentPurchaseButton; Debug.Log("showing confirmation dialog"); } }