UnityTips HealthBar

2018-12-28  本文已影响8人  RichMartin
public void UpdateHealthBar ()
    {
        // Set the health bar's colour to proportion of the way between green and red based on the player's health.
        healthBar.material.color = Color.Lerp(Color.green, Color.red, 1 - health * 0.01f);

        // Set the scale of the health bar to be proportional to the player's health.
        healthBar.transform.localScale = new Vector3(healthScale.x * health * 0.01f, 1, 1);
    }
上一篇 下一篇

猜你喜欢

热点阅读