using System; using System.Linq; using System.Threading; using Touka; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class ToukaAccountSDKDemo : MonoBehaviour { public Transform loading; public Transform loginView; public Transform userCenter; public Transform loginView_LoginChannelPanelRoot; public Transform userCenter_loginType; public Transform userCenter_userId; public Transform userCenter_token; public Transform userCenter_userType; public Transform btnBinded; public Transform btnBindGoogle; public Transform btnBindFacebook; public Transform PanelUserCenter_BindSelect; private string _userId; private string _token; private LoginType _userType; private LoginType _loginType; private Action _loginAction; private Action _bindAccountCallback; // Start is called before the first frame update void Start() { Loom.QueueOnMainThread((o => { }), ""); TKGSDKManager.Instance.InitSDK(() => { }); _loginAction = (status, type, msg, userid, token, email, displayName, photoUrl) => { Debug.Log($"登陆回调 {status} type:{type} msg:{msg} userId:{userid} token:{token}"); if (status == LoginStatus.LOGIN_STATUS_SUCC) { _userId = userid; _userType = type; _token = token; ShowUserCenter(); ToukaToast.ShowToast("登陆成功"); } else { _userId = ""; _userType = LoginType.LOGIN_BY_GUESTER; _token = ""; ToukaToast.ShowToast($"登陆失败:{msg}"); ShowLoginView(); } }; _bindAccountCallback = (status, loginTYpe, msg, userId, token, email, displayName, photoUrl, userIdList) => { Debug.Log( $"绑定回调 {status} type:{loginTYpe} msg:{msg} userId:{userId} token:{token} userIdList:{userIdList}"); if (status == BindAccountStatus.BIND_CODE_SELECT) { Debug.Log("绑定回调 - 选择界面"); InitBindSelectView(userIdList); return; } if (status == BindAccountStatus.BIND_CODE_SUCC) { Debug.Log("绑定回调 - 绑定成功"); if (!userId.Equals(_userId)) { Debug.Log($"绑定回调 - 绑定成功 - 重新登陆 userId:{userId} _userId:{_userId}"); CloseBindSelectView(); // 重新登陆了 ShowLoading(); return; } ToukaToast.ShowToast("绑定成功"); ShowUserCenter(); return; } ToukaToast.ShowToast($"绑定失败 {msg}"); }; ShowLoading(); } private static void CreateButton(Transform rootViewTransform, string content, out Button myButton) { var rootVector2 = rootViewTransform.GetComponent().sizeDelta; // 创建一个Button对象 var buttonGo = new GameObject("MyButton"); myButton = buttonGo.AddComponent