Ver código fonte

注册弹出协议

lvjincheng 3 anos atrás
pai
commit
6da52e0304

+ 5 - 4
Assets/BowArrow/Scripts/Manager/LoginView/AgreementPopup.cs

@@ -4,24 +4,25 @@ using UnityEngine;
 
 public class AgreementPopup : MonoBehaviour
 {
-    // Start is called before the first frame update
     void Start()
     {
         if (PlayerPrefs.GetInt("AgreementPopupChecked", 0) == 1) {
-            Destroy(gameObject);
+            this.gameObject.SetActive(false);
             LoginView.ins.SetAgreementChecked(true);
         }
     }
 
     public void Agree() {
         PlayerPrefs.SetInt("AgreementPopupChecked", 1);
-        Destroy(gameObject);
+        this.gameObject.SetActive(false);
         LoginView.ins.SetAgreementChecked(true);
     }
+    [System.NonSerialized] public System.Action onDisagree;
     public void Disagree() {
         PlayerPrefs.SetInt("AgreementPopupChecked", 0);
-        Destroy(gameObject);
+        this.gameObject.SetActive(false);
         LoginView.ins.SetAgreementChecked(false);
+        onDisagree?.Invoke();
     }
 
     public void EnterUserAgreement() {

+ 7 - 0
Assets/BowArrow/Scripts/Manager/LoginView/RegisterView.cs

@@ -29,6 +29,13 @@ public class RegisterView : MonoBehaviour
     void OnEnable() 
     {
         InitPage();
+        //弹出协议,不同意则退出注册
+        AgreementPopup agreementPopup = transform.parent.Find("AgreementPopup").GetComponent<AgreementPopup>();
+        agreementPopup.onDisagree = () => {
+            agreementPopup.onDisagree = null;
+            GameObject.FindObjectOfType<LoginMgr>().showLoginView();
+        };
+        agreementPopup.gameObject.SetActive(true);
     }
 
     void Start()