81 lines
1.7 KiB
C#
81 lines
1.7 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class NewsItem : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Image newsImage;
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI titleText;
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI contentText;
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI pagesText;
|
|
|
|
[SerializeField]
|
|
private Button prevPageButton;
|
|
|
|
[SerializeField]
|
|
private Button nextPageButton;
|
|
|
|
[SerializeField]
|
|
private Button closeButton;
|
|
|
|
[HideInInspector]
|
|
public UpdateWindowSystem updateWindowSystem;
|
|
|
|
public Sprite image;
|
|
|
|
public string title;
|
|
|
|
public string content;
|
|
|
|
public int actualIndex;
|
|
|
|
public int listSize;
|
|
|
|
public void Start()
|
|
{
|
|
prevPageButton.onClick.AddListener(PrevPage);
|
|
nextPageButton.onClick.AddListener(NextPage);
|
|
closeButton.onClick.AddListener(Close);
|
|
newsImage.sprite = image;
|
|
titleText.text = title;
|
|
contentText.text = content;
|
|
pagesText.text = actualIndex + 1 + "/" + listSize;
|
|
}
|
|
|
|
private void NextPage()
|
|
{
|
|
if (actualIndex < listSize - 1)
|
|
{
|
|
actualIndex++;
|
|
newsImage.sprite = updateWindowSystem.classList[actualIndex].image;
|
|
titleText.text = updateWindowSystem.classList[actualIndex].title;
|
|
contentText.text = updateWindowSystem.classList[actualIndex].contnet;
|
|
pagesText.text = actualIndex + 1 + "/" + listSize;
|
|
}
|
|
}
|
|
|
|
private void PrevPage()
|
|
{
|
|
if (actualIndex > 0)
|
|
{
|
|
actualIndex--;
|
|
newsImage.sprite = updateWindowSystem.classList[actualIndex].image;
|
|
titleText.text = updateWindowSystem.classList[actualIndex].title;
|
|
contentText.text = updateWindowSystem.classList[actualIndex].contnet;
|
|
pagesText.text = actualIndex + 1 + "/" + listSize;
|
|
}
|
|
}
|
|
|
|
private void Close()
|
|
{
|
|
Object.Destroy(base.gameObject);
|
|
}
|
|
}
|