예제 #1
0
        public override void RefreshUI()
        {
            // Sanity check: Don't refresh this window if it isn't enabled or
            if (IsEnabled && SelectedUnit != null)
            {
                // Minimum width of the hover summary window is 100f units
                var targetWidth = 100f;

                if (UnitNameText != null)
                {
                    UnitNameText.text = SelectedUnit.UnitName;
                    targetWidth       = Mathf.Max(targetWidth, UnitNameText.preferredWidth);
                }
                if (UnitHPText != null)
                {
                    UnitHPText.text = string.Format("HP: {0} / {1}", SelectedUnit.HP, SelectedUnit.GetAttribute(UnitAttribute.MaxHP));
                }
                if (UnitSPText != null)
                {
                    UnitSPText.text = string.Format("SP: {0} / {1}", SelectedUnit.SP, SelectedUnit.GetAttribute(UnitAttribute.MaxSP));
                }

                // Add our margins to the width of the window
                targetWidth += margin * 2;
                Window.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, targetWidth);
            }

            base.RefreshUI();
        }