Hey guys!
I’m a graphical artist who JUST started learning how to code.
I’ve succesfully made a progress bar that works when i change values in the inspector. (Progressbar Script)
I’ve also succesfully made a script that increase the resource “Evocado” by 1 every second.
These are two different scripts. Now the issues that I’m having is that I don’t know how to link the inspector value of the progress bar script to the increase in Evocados.
ProgressBar Script:
using UnityEngine;
using UnityEngine.UI;
[ExecuteInEditMode()]
public class ProgressBar : MonoBehaviour
{
public int maximum;
public int current;
public Image mask;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
GetCurrentFill();
}
void GetCurrentFill()
{
float fillAmount = (float)current / (float)maximum;
mask.fillAmount = fillAmount;
}
}
Here is the script for my Resource Generation:
using UnityEngine;
using UnityEngine.UI;
public class CurrencyHandler : MonoBehaviour
{
public static long EvoResourceAmount = 0;
public static long EvoResourceMax = 15;
public Text EvoResourceAmountText;
public float EvoTimer;
public float EvoTimerCount = 0;
// Start is called before the first frame update
void Start()
{
EvoTimerCount = Time.time+EvoTimer;
}
// Update is called once per frame
void Update()
{
EvoResourceAmountText.text = EvoResourceAmount.ToString() + "/" + EvoResourceMax.ToString();
if (EvoTimerCount < Time.time)
{
EvoResourceAmount = EvoResourceAmount + 1;
EvoTimerCount = Time.time + EvoTimer;
}
}
}
I’ve also uploaded an image of the UI, in case that helps.
I’d very much appreciate the help if you’re sitting there with all the knowledge
With that said, I hope you have an amazing day!