47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using tysdk;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SDKTest : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Button guestLoginBtn;
|
|
|
|
[SerializeField]
|
|
private Button googoleLoginBtn;
|
|
|
|
[SerializeField]
|
|
private Button facebookLoginBtn;
|
|
|
|
[SerializeField]
|
|
private Button LogOutBtn;
|
|
|
|
[SerializeField]
|
|
private Text log;
|
|
|
|
void Start()
|
|
{
|
|
guestLoginBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGuest));
|
|
googoleLoginBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGoogle));
|
|
facebookLoginBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwFacebook));
|
|
LogOutBtn.onClick.AddListener(OnLogout);
|
|
}
|
|
|
|
private async void OnLogin(EAccoutType accoutType)
|
|
{
|
|
log.text = string.Empty;
|
|
var info = await TYSdkFacade.Instance.Login(accoutType);
|
|
log.text = $"Login: {info.isSuccess}";
|
|
if(info.isSuccess)
|
|
{
|
|
log.text += $"\n{info.msg}";
|
|
log.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}";
|
|
}
|
|
}
|
|
|
|
private void OnLogout()
|
|
{
|
|
TYSdkFacade.Instance.Logout();
|
|
}
|
|
}
|