这是第一个 Unity 开放项目的repo,是 Unity 和社区合作创建的一个小型开源游戏演示,第一款游戏是一款名为 Chop Chop 的动作冒险游戏。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

63 行
1.4 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Localization.Components;
using TMPro;
public class UIInspectorIngredientFiller : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI _ingredientAmount = default;
[SerializeField]
private GameObject _availableCheckMark = default;
[SerializeField]
private GameObject _unavailableCheckMark = default;
[SerializeField]
private GameObject _tooltip = default;
[SerializeField]
private LocalizeStringEvent _tooltipMessage = default;
[SerializeField]
private Image _ingredientIcon = default;
[SerializeField]
private Color _textColorAvailable = default;
[SerializeField]
private Color _textColorUnavailable = default;
public void FillIngredient(ItemStack ingredient, bool isAvailable)
{
if (isAvailable)
{
_ingredientAmount.color = _textColorAvailable;
}
else
{
_ingredientAmount.color = _textColorUnavailable;
}
_ingredientAmount.text = ingredient.Amount.ToString();
_tooltipMessage.StringReference = ingredient.Item.Name;
_tooltipMessage.StringReference.Arguments = new[] { new { Amount = ingredient.Amount } };
_ingredientIcon.sprite = ingredient.Item.PreviewImage;
_availableCheckMark.SetActive(isAvailable);
_unavailableCheckMark.SetActive(!isAvailable);
}
public void HoveredItem()
{
_tooltip.SetActive(true);
}
public void UnHoveredItem()
{
_tooltip.SetActive(false);
}
}