What would be the fastest and most performant method/code, to show during gameplay constantly updating donut charts.
Let’s keep it simple:
- donut chart has 2 colors (green and red)
- input/parameters: 2 values: count & totalBlocks
- donut chart color green = percentage for count
- donut chart color red = percentage for totalBlocks
Step 1. Calculate percentages
int totalBlocks = 12; //total items to collect
int count; //count++ each time an item is collected
int percentComplete = (int)(0.5f + ((100f * count) / totalBlocks));
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pick Up"))
{
count++;
int totalBlocks = 12;
int percentComplete = (int)(0.5f + ((100f * count) / totalBlocks));
other.gameObject.SetActive(false); //inactive collected block
}
}
Step 2. Create donut using percentageComplete as Green, rest as Red
…
Thanks for the help