Example #1
0
        void Update()
        {
            float trackFuel   = 0f;
            float currentFuel = fuel.GetCurrentFuel(trackFuel);

            if (currentFuel < Mathf.Epsilon)
            {
                currentFuel = 0f; // do not display negative value
            }
            if (currentFuel > defaultValue)
            {
                currentFuel = defaultValue;
            }

            double percentage = percentValue.GetPercentageValue(currentFuel, defaultValue);

            GetComponent <Text>().text = String.Format("{0:0} %", percentage);
        }
Example #2
0
        void Update()
        {
            float trackHealth   = 0f;
            float currentHealth = health.GetCurrentHealth(trackHealth);

            if (currentHealth < Mathf.Epsilon)
            {
                currentHealth = 0f; // do not display negative value
            }
            if (currentHealth > defaultValue)
            {
                currentHealth = defaultValue;
            }

            double percentage = percentValue.GetPercentageValue(currentHealth, defaultValue);

            GetComponent <Text>().text = String.Format("{0:0} %", percentage);
        }