| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- public class ModalDeleteAccount : MonoBehaviour
- {
- [SerializeField] GameObject content;
- private void Awake()
- {
- var tal = content.GetComponent<TextAutoLanguage2>();
- tal.textFormatArgs = new object[] { LoginMgr.myUserInfo.nickname };
- tal.ApplyToText();
- }
- public void OnCLick_Yes()
- {
- AudioMgr.ins.PlayBtn();
- GetComponentInParent<PersonalView>().ShowModalDeleteAccount(false);
- DeleteAccount();
- }
- public void OnCLick_No()
- {
- AudioMgr.ins.PlayBtn();
- GetComponentInParent<PersonalView>().ShowModalDeleteAccount(false);
- }
- [SerializeField] GameObject prefabValidateJigsaw;
- void DeleteAccount()
- {
- var validateJigsawView = Instantiate(prefabValidateJigsaw).GetComponent<JCUnityLib.UI.ValidateJigsawView>();
- JCUnityLib.CanvasUtils.PlusSortOrder(GetComponentInParent<Canvas>().gameObject, validateJigsawView.gameObject, 1);
- validateJigsawView.SetTextLabel(TextAutoLanguage2.GetTextByKey("ValidateJigsawView_label"));
- validateJigsawView.SetTextTip(TextAutoLanguage2.GetTextByKey("ValidateJigsawView_tip"));
- validateJigsawView.SetTextOK(TextAutoLanguage2.GetTextByKey("ValidateJigsawView_ok"));
- validateJigsawView.onComplete += () =>
- {
- //如果存在苹果登录记录,先清除登录苹果记录
- if (AppleLoginHelper.ins.HasAppleKey())
- AppleLoginHelper.ins.SignInWithAppleButtonPressedDelete(()=> {
- GetComponentInParent<PersonalView>().StartCoroutine(RunDeleteAccount());
- },()=> {
- });
- else
- GetComponentInParent<PersonalView>().StartCoroutine(RunDeleteAccount());
- };
- }
- IEnumerator RunDeleteAccount()
- {
- Transform tf = transform.parent.Find("AccountDeleting");
- Text textUI = tf.GetComponentInChildren<Text>();
- TextAutoLanguage2 tal2 = tf.GetComponentInChildren<TextAutoLanguage2>();
- Color textColor = Color.white;
- tal2.SetTextKey("me_delete-account-c4");
- textUI.color = textColor;
- tf.gameObject.SetActive(true);
- string textKey = null;
- bool deleteSuccess = false;
- UserComp.Instance.deleteAccount((success) =>
- {
- deleteSuccess = success;
- if (success)
- {
- textKey = "me_delete-account-c5";
- textColor = Color.green;
- }
- else
- {
- textKey = "me_delete-account-c6";
- textColor = Color.red;
- }
- });
- while (textKey == null) yield return new WaitForSecondsRealtime(2);
- tal2.SetTextKey(textKey);
- textUI.color = textColor;
- yield return new WaitForSecondsRealtime(2);
- if (deleteSuccess)
- {
- PlayerPrefs.DeleteKey(LoginMgr.LoginTokenKey);
- UserPlayer.ins?.Close();
- UnityEngine.SceneManagement.SceneManager.LoadScene("Login", UnityEngine.SceneManagement.LoadSceneMode.Single);
- }
- else
- {
- tf.gameObject.SetActive(false);
- }
- }
- }
|