35 lines
991 B
C#
35 lines
991 B
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AZTECHWB
|
|
{
|
|
public class UI_LibraryButton : MonoBehaviour
|
|
{
|
|
public Machine machine;
|
|
public event Action<UI_LibraryButton> onClickButton;
|
|
public Image PreviewImage;
|
|
public Image Image_Selected;
|
|
|
|
public void SettingButton(Machine machine)
|
|
{
|
|
this.machine = machine;
|
|
|
|
var button = GetComponent<Button>();
|
|
var buttonText = button.GetComponentInChildren<TMP_Text>();
|
|
PreviewImage = transform.Find(nameof(PreviewImage)).GetComponent<Image>();
|
|
Image_Selected = transform.Find(nameof(Image_Selected)).GetComponent<Image>();
|
|
|
|
buttonText.SetText(machine.machineName);
|
|
button.onClick.AddListener(OnButtonClick);
|
|
PreviewImage.sprite = machine.previewImage;
|
|
}
|
|
private void OnButtonClick()
|
|
{
|
|
onClickButton?.Invoke(this);
|
|
}
|
|
}
|
|
}
|
|
|