Files

49 lines
1.7 KiB
C#
Raw Permalink Normal View History

2023-08-09 09:48:11 +03:00
using TMPro;
using UnityEngine;
using Unity.Services.Authentication;
using Unity.Services.Core;
public class HomeMenu : BaseMenu
{
[SerializeField] private PlayerUIRender _playerUIRender = default;
2023-12-29 13:54:08 +02:00
[SerializeField] private PlayerUIRender _playerOnlineUIRender = default;
2023-08-09 09:48:11 +03:00
[SerializeField] private TextMeshProUGUI _playerName = default;
2023-12-29 13:54:08 +02:00
[SerializeField] private TextMeshProUGUI _playerOnlineProfileName = default;
2023-10-03 11:33:37 +03:00
[SerializeField] private TextMeshProUGUI _playerProfileName = default;
2023-12-01 20:56:18 +02:00
[SerializeField] private TextMeshProUGUI _onlineInfoText = default;
[SerializeField] private Animator _onlineInfoAnimator = default;
2023-08-09 09:48:11 +03:00
[SerializeField] private PlayerStatsSO[] _playerStatsSO = default;
async private void Awake()
{
await UnityServices.InitializeAsync();
2023-10-24 00:32:35 +03:00
if (!AuthenticationService.Instance.IsAuthorized)
await AuthenticationService.Instance.SignInAnonymouslyAsync();
2023-08-09 09:48:11 +03:00
}
2023-12-01 20:56:18 +02:00
private void Start()
{
#if UNITY_WEBGL
_onlineInfoText.text = "Unavailable on Web";
_onlineInfoAnimator.Play("ButtonDisable");
#endif
#if !UNITY_WEBGL
2023-12-03 02:36:58 +02:00
_onlineInfoText.text = "Early Version";
2023-12-01 20:56:18 +02:00
#endif
}
2023-08-09 09:48:11 +03:00
public void SetCharacter(int character, int color, string playerName)
{
_playerUIRender.gameObject.SetActive(true);
_playerName.text = playerName;
2023-10-03 11:33:37 +03:00
_playerProfileName.text = playerName;
2023-12-29 13:54:08 +02:00
_playerOnlineProfileName.text = playerName;
2023-08-09 09:48:11 +03:00
_playerUIRender.SetAnimator(_playerStatsSO[character]._animation);
_playerUIRender.SetSpriteLibraryAsset(color);
2023-12-29 13:54:08 +02:00
_playerOnlineUIRender.SetAnimator(_playerStatsSO[character]._animation);
_playerOnlineUIRender.SetSpriteLibraryAsset(color);
_playerProfileName.text = playerName;
2023-08-09 09:48:11 +03:00
}
}