Hi, I have written this code to activate my buttons.
however when you clock on the buttons in the scene they do not seam to do anything
however their are no errors in the code…
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PurchaceFighter07 : MonoBehaviour {
public float RequiredSpaceGold = 1000;
public GameObject PurchaceFighter07Button; // use this is the fighter is yet to be unlociked.
public GameObject Fighter07buttonUnlocked; //this if used if fighter is unlocked already.
public float UnlockedRequirement = 1; // used to see what button to display locked or unlocked.
public GameObject NotEnoughGoldButton; //this if used if fighter is unlocked already.
void OnGUI () {
if(global.Fighter07Purchace > UnlockedRequirement){
PurchaceFighter07Button.SetActive(false);
Fighter07buttonUnlocked.SetActive(true);
// swap Locked button to Unlocked button that if User has unlocked this on his/her acount
}
else //if the fighter is locked allow users to purchase.
{
PurchaceFighter07Button.GetComponent<Button>().onClick.AddListener(() => {UnlockFigheter07(); }); // if avaible and you click this button use this fighter.
}
}
void UnlockFigheter07 () // if use has enoughg spacegold, purchace fighter, if not display error button.
{
if (global.SpaceGold > RequiredSpaceGold)
{
global.Fighter07Purchace += +2;
global.SpaceGold += -1000;
PurchaceFighter07Button.SetActive(false);
Fighter07buttonUnlocked.SetActive(true);
} // if the fighter is already purchased set as unlocked.
else
{
if (global.SpaceGold < RequiredSpaceGold) // If User dose Not have Enough SpaceGold.
NotEnoughGoldButton.SetActive(true); // NOT ENOUGH GOLD EARN OR PURCHACE! CLICK TO CONTINUE.
}
} // end of Fighter Purchaced
} /// End Of Class