Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.Networking;
  6.  
  7. public class GDPRChecker : MonoBehaviour
  8. {
  9.     public GDPRChecker Instance;
  10.     public bool ConsentRequired = false;
  11.  
  12.     void Awake()
  13.     {
  14.         Instance = this;
  15.     }
  16.  
  17.     void Start()
  18.     {
  19.         StartCoroutine(CheckGDPR());
  20.     }
  21.  
  22.  
  23.  
  24.     IEnumerator CheckGDPR()
  25.     {
  26.         using (UnityWebRequest www = UnityWebRequest.Get("http://adservice.google.com/getconfig/pubvendors"))
  27.         {
  28.             yield return www.SendWebRequest();
  29.  
  30.             if (www.isNetworkError || www.isHttpError)
  31.             {
  32.                 Debug.Log(www.error);
  33.             }
  34.             else
  35.             {
  36.                 string requestResult = www.downloadHandler.text;
  37.  
  38.                 Debug.Log(requestResult);
  39.  
  40.                 ConsentRequired = requestResult.Contains("true");
  41.  
  42.             }
  43.  
  44.         }
  45.  
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement