I want to “clamp” the filled amount of an image with 360° radial like this:
I have:
float max_amount = 500f;
float cur_amount = max_amount;
float minValue = 0.1f;
float maxValue = 0.35f;
cur_amount needs to be calculated to fit a radial circle segment fill from 0.1f(minValue) to 0.35f(maxValue).
How can i calculate the fillamount?
Normally i do this for the 360° complete circle.
float calc_amount = cur_amount/max_amount;
@OctoMan
your code was a great help thank you
//Otimized!!
Healthbar.fillAmount = (cur_amount/max_amount)*(maxValue - minValue)+minValue;
Hi, I am not sure whether my answer is what you want
using System.Collections;
using UnityEngine.UI;
public class test : MonoBehaviour {
float min_amount = 0.1f;
float max_amount = 0.35f;
float calc_amount;
Image image;
public float input;
// Update is called once per frame
void Update () {
if (input <= max_amount && input > min_amount)
calc_amount = (input - min_amount) / (max_amount - min_amount);
image = gameObject.GetComponent<Image>();
image.fillAmount = calc_amount;
}
}