| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /* 弹窗-用户协议和隐私政策 */
- public class AgreementPopup : MonoBehaviour, MenuBackInterface
- {
- void Awake() {
- HyperlinkText hyperlinkText = null;
- if (TextAutoLanguage2.GetLanguage() == LanguageEnum.Chinese) {
- transform.Find("ContentBG").gameObject.SetActive(true);
- } else {
- Transform content = transform.Find("ContentBG_en");
- content.gameObject.SetActive(true);
- hyperlinkText = content.GetComponentInChildren<HyperlinkText>();
- }
- if (hyperlinkText) {
- hyperlinkText.onClickHref += (val) => {
- if (val == "a") EnterUserAgreement();
- else if (val == "b") EnterPrivacyAgreement();
- };
- }
- }
- void OnEnable()
- {
- PersistenHandler.ins?.menuBackCtr.views.Add(this);
- }
- void OnDisable()
- {
- PersistenHandler.ins?.menuBackCtr.views.Remove(this);
- }
-
- void Start()
- {
- if (PlayerPrefs.GetInt("AgreementPopupChecked", 0) == 1) {
- this.gameObject.SetActive(false);
- AgreenmentOption.ins.SetAgreementChecked(true);
- }
- }
- public bool OnMenuBack() {
- Disagree();
- return true;
- }
- public void Agree() {
- PlayerPrefs.SetInt("AgreementPopupChecked", 1);
- this.gameObject.SetActive(false);
- AgreenmentOption.ins.SetAgreementChecked(true);
- }
- [System.NonSerialized] public System.Action onDisagree;
- public void Disagree() {
- PlayerPrefs.SetInt("AgreementPopupChecked", 0);
- this.gameObject.SetActive(false);
- AgreenmentOption.ins.SetAgreementChecked(false);
- onDisagree?.Invoke();
- }
- public void EnterUserAgreement() {
- GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
- o.GetComponent<AgreementView>().EnterUserAgreement();
- }
- public void EnterPrivacyAgreement() {
- GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
- o.GetComponent<AgreementView>().EnterPrivacyAgreement();
- }
- }
|