コード例 #1
0
ファイル: HealthBar.cs プロジェクト: leozhang1/FirstRPG
        // get health component percentage decimal value, then assign
        // rect transform scale's x-value to that
        public void HandleHealth()
        {
            // hides the health bar once the enemy dies
            // and also hides it when it is full
            if (Mathf.Approximately(healthComponent.GetHealthDecimalValue(), 0) ||
                Mathf.Approximately(healthComponent.GetHealthDecimalValue(), 1))
            {
                canvas.enabled = false;
                return;
            }

            canvas.enabled = true;

            foregroundRectTransform.localScale =
                new Vector3(healthComponent.GetHealthDecimalValue(), 1, 1);
        }