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(); } 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("Prefabs/Views/AgreementView")); o.GetComponent().EnterUserAgreement(); } public void EnterPrivacyAgreement() { GameObject o = GameObject.Instantiate(Resources.Load("Prefabs/Views/AgreementView")); o.GetComponent().EnterPrivacyAgreement(); } }