// Called on the "Buy" button (the one that shows the price in the screen) public void Button_Buy() { // Just to confirm that we are in the right screen when the button was pressed if (!mainScript.isConfirmingPurchase) { mainScript.isConfirmingPurchase = true; // Getting info about the character that the player wants to buy CharacterSelection.CharacterSetup selectedCharacter = mainScript.GetHighlightedCharacter(); // If the player have enough coins if (mainScript.IsPurchasePossible()) { // Set the text asking if the player wants to confirm the purchase mainScript.confirmPurchaseText.text = "Confirm the purchase of " + selectedCharacter.name + " for " + selectedCharacter.price.ToString() + " coins?"; } // If the player doesn't have enough coins, // Set the text to tell how much coins is need to be able to buy the selected character else { mainScript.confirmPurchaseText.text = "You need more " + (selectedCharacter.price - mainScript.CoinsCollected).ToString() + " coins to be able to buy " + selectedCharacter.name; } // Olny show the "Confirm Purchase" button if the player have enough coins mainScript.confirmPurchaseButton.SetActive(mainScript.CoinsCollected >= selectedCharacter.price); // Here I am using my animation script to smoothly show the "Confirm purchase" screen // but you can edit it to your own way mainScript.confirmPurchaseScreen.GetComponent <UIAnimation>().PlayAnimation("In"); } }