using TMPro; using UnityEngine; using UnityEngine.UI; public class ItemPrefab : MonoBehaviour, System.IEquatable { [SerializeField] Library _library; public Library library { get { return _library; } } [SerializeField] TMP_Text suitName; [SerializeField] TMP_Text ownerName; [SerializeField] RawImage suitImage; public void Set(Library library) { this._library = library; suitName.text = library.suit_name; ownerName.text = library.owner_name; //if(_library._suit_image == null) // SearchCtrl.Instance.GetImage(this, _library); //else // ImageSet(); } public void ImageSet() { suitImage.texture = library._suit_image; suitImage.SetNativeSize(); RectTransform rect = suitImage.gameObject.GetComponent(); rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); float size = rect.sizeDelta.y / 500; Vector2 newSize = new Vector2(rect.sizeDelta.x / size, rect.sizeDelta.y /size); rect.sizeDelta = newSize; } public void Button() { SearchCtrl.Instance.ModelSet(_library); } public bool Equals(ItemPrefab other) { return (_library?.Equals(other?._library) == true) && ReferenceEquals(this, other); } }