public void SaveConsent()
 {
     if (!string.IsNullOrEmpty(section.identifier))
     {
         GDPRConsentCanvas.SetConsentState(section.identifier, toggleHolder.Value ? SimpleGDPR.ConsentState.Yes : SimpleGDPR.ConsentState.No);
     }
 }
Ejemplo n.º 2
0
        private void Awake()
        {
            if (m_instance == null)
            {
                m_instance = this;
                DontDestroyOnLoad(gameObject);
                gameObject.SetActive(false);
            }
            else if (this != m_instance)
            {
                Destroy(gameObject);
                return;
            }

            acceptButton.onClick.AddListener(OnAcceptTermsButtonClicked);
            closeButton.onClick.AddListener(OnCloseDialogButtonClicked);

            sectionSeparatorsUI.Add((RectTransform)Instantiate(horizontalLinePrefab, sectionsParent, false));
            contentPaddingY = -((RectTransform)scrollView.transform).sizeDelta.y + 5f;

#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS)
            // On mobile platforms, ScreenMatchMode.Shrink makes texts larger (legible) on landscape orientation
            GetComponent <CanvasScaler>().screenMatchMode = CanvasScaler.ScreenMatchMode.Shrink;
#endif
        }
        public void Initialize(GDPRConsentDialog.Section section)
        {
            this.section = section;

            if (!string.IsNullOrEmpty(section.description))
            {
                description.text = section.description;
                description.gameObject.SetActive(true);
            }
            else
            {
                description.gameObject.SetActive(false);
            }

            if (!string.IsNullOrEmpty(section.title))
            {
                title.text = section.title;
                title.gameObject.SetActive(true);
            }
            else
            {
                title.gameObject.SetActive(false);
            }

            if (!string.IsNullOrEmpty(section.identifier))
            {
                toggle.gameObject.SetActive(true);

                SimpleGDPR.ConsentState consentState = GDPRConsentCanvas.GetConsentState(section.identifier);
                if (consentState == SimpleGDPR.ConsentState.Unknown)
                {
                    toggleHolder.Value = section.initialConsentValue;
                }
                else
                {
                    toggleHolder.Value = consentState != SimpleGDPR.ConsentState.No;
                }
            }
            else
            {
                toggle.gameObject.SetActive(false);
            }

            if (section.onButtonClicked != null)
            {
                buttonLabel.text = !string.IsNullOrEmpty(section.buttonLabel) ? section.buttonLabel : "Configure";
                button.gameObject.SetActive(true);
            }
            else
            {
                button.gameObject.SetActive(false);
            }

            toggleHolder.gameObject.SetActive(toggle.gameObject.activeSelf || title.gameObject.activeSelf);
        }