AgreenmentOption.cs 1.2 KB

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