AgreementPopup.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class AgreementPopup : MonoBehaviour
  5. {
  6. void Awake() {
  7. HyperlinkText hyperlinkText = null;
  8. if (TextAutoLanguage2.GetLanguage() == LanguageEnum.Chinese) {
  9. transform.Find("ContentBG").gameObject.SetActive(true);
  10. } else {
  11. Transform content = transform.Find("ContentBG_en");
  12. content.gameObject.SetActive(true);
  13. hyperlinkText = content.GetComponentInChildren<HyperlinkText>();
  14. }
  15. if (hyperlinkText) {
  16. hyperlinkText.onClickHref += (val) => {
  17. if (val == "a") EnterUserAgreement();
  18. else if (val == "b") EnterPrivacyAgreement();
  19. };
  20. }
  21. }
  22. void Start()
  23. {
  24. if (PlayerPrefs.GetInt("AgreementPopupChecked", 0) == 1) {
  25. this.gameObject.SetActive(false);
  26. AgreenmentOption.ins.SetAgreementChecked(true);
  27. }
  28. }
  29. public void Agree() {
  30. PlayerPrefs.SetInt("AgreementPopupChecked", 1);
  31. this.gameObject.SetActive(false);
  32. AgreenmentOption.ins.SetAgreementChecked(true);
  33. }
  34. [System.NonSerialized] public System.Action onDisagree;
  35. public void Disagree() {
  36. PlayerPrefs.SetInt("AgreementPopupChecked", 0);
  37. this.gameObject.SetActive(false);
  38. AgreenmentOption.ins.SetAgreementChecked(false);
  39. onDisagree?.Invoke();
  40. }
  41. public void EnterUserAgreement() {
  42. GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
  43. o.GetComponent<AgreementView>().EnterUserAgreement();
  44. }
  45. public void EnterPrivacyAgreement() {
  46. GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
  47. o.GetComponent<AgreementView>().EnterPrivacyAgreement();
  48. }
  49. }