示例#1
0
        public void Set(
            ItemBase itemBase,
            Action <EquipmentSlot> onClick,
            Action <EquipmentSlot> onDoubleClick)
        {
            if (itemBase is null)
            {
                Clear();

                _onClick       = onClick;
                _onDoubleClick = onDoubleClick;
                return;
            }

            var sprite = itemBase.GetIconSprite();

            if (defaultImage)
            {
                defaultImage.enabled = false;
            }

            itemImage.enabled        = true;
            itemImage.overrideSprite = sprite;
            itemImage.SetNativeSize();
            Item = itemBase;

            var gradeSprite = itemBase.GetBackgroundSprite();

            if (gradeSprite is null)
            {
                throw new FailedToLoadResourceException <Sprite>(itemBase.Grade.ToString());
            }

            gradeImage.enabled        = true;
            gradeImage.overrideSprite = gradeSprite;

            if (itemBase is Equipment equip && equip.level > 0)
            {
                enhancementText.enabled = true;
                enhancementText.text    = $"+{equip.level}";
            }