Item.cs 786 B

1234567891011121314151617181920212223
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace SoftMasking.Samples {
  4. public class Item : MonoBehaviour {
  5. public Image image;
  6. public Text title;
  7. public Text description;
  8. public RectTransform healthBar;
  9. public RectTransform damageBar;
  10. public void Set(string name, Sprite sprite, Color color, float health, float damage) {
  11. if (image) {
  12. image.sprite = sprite;
  13. image.color = color;
  14. }
  15. if (title) title.text = name;
  16. if (description) description.text = "The short description of " + name;
  17. if (healthBar) healthBar.anchorMax = new Vector2(health, 1);
  18. if (damageBar) damageBar.anchorMax = new Vector2(damage, 1);
  19. }
  20. }
  21. }