73 lines
2.8 KiB
C#
73 lines
2.8 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.UI;
|
|
|
|
public class MenuScript : MonoBehaviour
|
|
{
|
|
[SerializeField] private Button closeButton;
|
|
[SerializeField] private TMP_Text updateText;
|
|
[SerializeField] private Button updateButton;
|
|
[SerializeField] private TMP_Text splashText;
|
|
[SerializeField] private Button profileButton;
|
|
[SerializeField] private ProfileMenu profilePrefab;
|
|
[SerializeField] private TMP_Text copyrightText;
|
|
[SerializeField] private GameObject closePopup;
|
|
[SerializeField] private Button closePopupCancelButton;
|
|
[SerializeField] private Button closePopupCloseButton;
|
|
[SerializeField] private Button iconMarketplaceButton;
|
|
[SerializeField] private TMP_Text iconMarketplaceButtonText;
|
|
|
|
void Awake()
|
|
{
|
|
if (PresistentData.latestVersion != null)
|
|
{
|
|
if (PresistentData.latestVersion != "-1")
|
|
{
|
|
updateText.text = "Latest: v" + PresistentData.latestVersion ?? "N/A";
|
|
updateButton.gameObject.SetActive(PresistentData.latestVersion != Application.version);
|
|
}
|
|
else
|
|
{
|
|
updateText.text = "Latest: Loading...";
|
|
}
|
|
}
|
|
if (PresistentData.randomSplashes != null) splashText.text = PresistentData.randomSplashes[Random.Range(0, PresistentData.randomSplashes.Length)];
|
|
copyrightText.text = $"\\u00A9 {System.DateTime.Now.Year} Lncvrt. All rights reserved.";
|
|
|
|
if (!Application.isMobilePlatform && !Application.isEditor)
|
|
{
|
|
closeButton.gameObject.SetActive(true);
|
|
closeButton.onClick.AddListener(() => closePopup.SetActive(true));
|
|
}
|
|
|
|
closePopupCancelButton.onClick.AddListener(() => closePopup.SetActive(false));
|
|
closePopupCloseButton.onClick.AddListener(() => Application.Quit());
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
if (BazookaManager.Instance.GetAccountID() != null)
|
|
{
|
|
profileButton.transform.GetChild(0).GetComponent<TMP_Text>().text = BazookaManager.Instance.GetAccountName();
|
|
profileButton.onClick.AddListener(async () =>
|
|
{
|
|
var clone = Instantiate(profilePrefab.gameObject, profilePrefab.gameObject.transform.parent);
|
|
clone.SetActive(true);
|
|
await clone.GetComponent<ProfileMenu>().Init();
|
|
});
|
|
profileButton.gameObject.SetActive(true);
|
|
}
|
|
|
|
if (Tools.GetLevelInfo().level < 3)
|
|
{
|
|
iconMarketplaceButton.interactable = false;
|
|
iconMarketplaceButtonText.text += "\n<size=12>You need level 3 or higher to access this</size>";
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (Keyboard.current.escapeKey.wasPressedThisFrame && !GameObject.Find("ProfilePrefab(Clone)")) closePopup.SetActive(!closePopup.activeSelf);
|
|
}
|
|
} |