| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- /* 勾选框-用户协议和隐私政策 */
- public class AgreenmentOption : MonoBehaviour
- {
- public static AgreenmentOption ins;
- Toggle toggle;
- void Awake()
- {
- //ins = this;
- toggle = transform.Find("Toggle").GetComponent<Toggle>();
- InitAgreementOnClickListeners();
- }
- void OnEnable()
- {
- if (ins == null || !ins.gameObject.activeInHierarchy)
- {
- ins = this;
- Debug.Log("AgreenmentOption:"+ ins.transform.parent.parent.name + " is active in hierarchy.");
- }
- }
- void OnDestroy()
- {
- if (ins == this) ins = null;
- }
- void InitAgreementOnClickListeners()
- {
- transform.Find("TextA").GetComponent<Button>().onClick.AddListener(delegate ()
- {
- GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
- o.GetComponent<AgreementView>().EnterUserAgreement();
- });
- transform.Find("TextB").GetComponent<Button>().onClick.AddListener(delegate ()
- {
- GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
- o.GetComponent<AgreementView>().EnterPrivacyAgreement();
- });
- }
- public bool IsAgreementChecked()
- {
- //transform.Find("Toggle").GetComponent<Toggle>()
- return toggle.isOn;
- }
- public void SetAgreementChecked(bool value)
- {
- toggle.isOn = value;
- }
- }
|