Get Value To Fill Image

I’m trying to make a visible battery indicator for my Android App, So far I can get this to read the battery level on my Android device as a UI text but I want to use a fill image as a battery indicator. Can anyone help me out with how to do this if it’s possible.

int GetBatteryLevel()
    {
        try
        {
            string CapacityString = System.IO.File.ReadAllText("/sys/class/power_supply/battery/capacity");
            BatLevelText.text = ("BATTERY LEVEL: " + CapacityString);
           
            return int.Parse(CapacityString);
           
        }
        catch (System.Exception e)
        {
            //Debug.Log("Failed to read battery power; " + e.Message);
            //print("Bat Life: " + e.Message);

            testText.text = e.Message.ToString();
        }

        return -1; //if no value is found
    }

Thanks Star Manta, I already have a fill bar set up but I’m not sure how to use the data in the “GetBatteryLevel()” to update my fill meter??

So you basically need to convert a 1-to-100 int value to a 0-to-1 float value then?

float fValue = (float)GetBatteryLevel() / 100f;

Do I put that in update and access my fill bar using that?

I also notce he’s using two different int’s for his health bar??? Would I not just need one that is just a float??

Just experimenting but is this on the right track?

float fValue = (float)GetBatteryLevel() / 100f;
Debug.Log(fValue);
batteryLevelBar.fillAmount = fValue;

I can’t test it on my PC I would have to upload it to my Android device in order to test each time