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; [SerializeField] GameObject loading; public void Set(Library library) { this._library = library; suitName.text = library.suit_name; ownerName.text = library.owner_name; if(library._suit_image == null) { loading.SetActive(true); suitImage.texture = null; } } private void Update() { if (loading.activeSelf) { loading.transform.rotation *= Quaternion.Euler(0, 0, 5); } } public void ImageSet() { loading.SetActive(false); 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); } }