It Only Gives Me one Every Time I Click The Purchase Button,using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AutoScript : MonoBehaviour
{
void Start()
{
I guess you actually want something like this instead:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AutoScript : MonoBehaviour
{
void Start()
{
InvokeRepeating("GiveCamera", 1, 1f);
}
public void GiveCamera()
{
CameraAmount.CameraAmounts += PurchaseAutoOnClick.PurchaseClicked;
}
}
Start is only called once at the very start of the game. So your InvokeRepeating would not execute unless your “PurchaseClicked” value is greater than 1 (so 2 or higher). If the value changes later, the InvokeRepeating would not magically be started then. Again, Start is only called once. What I did is I start the InvokeRepeating immediately. Assuming “PurchaseClicked” is 0 initially, when we add 0 to “CameraAmounts”, nothing would change. However as PurchaseClicked is increased we add that amount each second.