54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ItemPrefab : MonoBehaviour, System.IEquatable<ItemPrefab>
|
|
{
|
|
[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;
|
|
}
|
|
|
|
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<RectTransform>();
|
|
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);
|
|
}
|
|
}
|