AgreenmentOption.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. /* 勾选框-用户协议和隐私政策 */
  7. public class AgreenmentOption : MonoBehaviour
  8. {
  9. public static AgreenmentOption ins;
  10. Toggle toggle;
  11. void Awake() {
  12. ins = this;
  13. toggle = transform.Find("Toggle").GetComponent<Toggle>();
  14. InitAgreementOnClickListeners();
  15. }
  16. void OnDestroy() {
  17. if (ins == this) ins = null;
  18. }
  19. void InitAgreementOnClickListeners() {
  20. transform.Find("TextA").GetComponent<Button>().onClick.AddListener(delegate() {
  21. GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
  22. o.GetComponent<AgreementView>().EnterUserAgreement();
  23. });
  24. transform.Find("TextB").GetComponent<Button>().onClick.AddListener(delegate() {
  25. GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
  26. o.GetComponent<AgreementView>().EnterPrivacyAgreement();
  27. });
  28. }
  29. public bool IsAgreementChecked() {
  30. //transform.Find("Toggle").GetComponent<Toggle>()
  31. return toggle.isOn;
  32. }
  33. public void SetAgreementChecked(bool value) {
  34. toggle.isOn = value;
  35. }
  36. }