| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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 = TextAutoLanguage2.GetLanguage() == LanguageEnum.Japan? transform.Find("ContentBG_jp") : 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();
- }
- }
|