IEnumerator GetJsonOnline()
        {
            UnityWebRequest www = UnityWebRequest.Get(JsonUrl);

            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log("network error" + www.error);
                Debug.Log("asdf " + networkPanel);
                //todo
                //networkPanel.SetActive(true);
                yield break;
            }
            else
            {
                //todo
                // networkPanel.SetActive(false);
            }

            //    ImageTargetVideoUrlTemplate ImageVideoSet1 = new ImageTargetVideoUrlTemplate();
            ImageVideoTemplateCollection collection = new ImageVideoTemplateCollection();

            collection = JsonUtility.FromJson <ImageVideoTemplateCollection>(www.downloadHandler.text);
            Debug.Log(collection);
            for (int i = 0; i < collection.arList.Length; i++)
            {
                //todo uncomment following event line
                //   urlDownloadedEvent?.Invoke(collection.arList[i]);
                GameObject.FindObjectOfType <DynamicImageTarget>().DownloadImageFromServerFunc(collection.arList[i]);
                //check the ad and project id

                //if (collection.arList[i].project_id != null)
                //{
                //    IdManager.Instance.projectId = collection.arList[i].project_id;
                //    Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "project_id", collection.arList[i].project_id);
                //    Debug.Log("Project_id " + collection.arList[i].project_id);
                //}
                //if (collection.arList[i].advertisement_id != null)
                //{
                //    IdManager.Instance.advertisementId = collection.arList[i].advertisement_id;
                //    Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "advertisement_id", collection.arList[i].advertisement_id);
                //    Debug.Log("Advertisement_id " + collection.arList[i].advertisement_id);
                //}
                //if (collection.arList[i].promotion_id != null)
                //{
                //    IdManager.Instance.PromotionId = collection.arList[i].promotion_id;
                //    Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "promotion_id", collection.arList[i].promotion_id);
                //    Debug.Log("Promotion_id " + collection.arList[i].promotion_id);
                //}
                //IdManager.Instance.template = collection.arList[i];

                Debug.Log("image url " + i + collection.arList[i].targetImageUrl);
                Debug.Log("video url " + i + collection.arList[i].targetVideoUrl);
            }
        }
        //if we get json from native
        public void JsonFromNative(string s)
        {
            //turn on scan panel because this is the entry point from native to unity
            GameObject.FindObjectOfType <HUDManager>().TurnOnScanpanel();
            print("got json" + s);

            Debug.Log("got info from native" + s);


            ImageVideoTemplateCollection collection = new ImageVideoTemplateCollection();

            collection = JsonUtility.FromJson <ImageVideoTemplateCollection>(s);
            Debug.Log(collection);
            for (int i = 0; i < collection.arList.Length; i++)
            {
                /* if(downloadedUrls.Contains(collection.arList[i].targetImageUrl))
                 * {
                 *   Debug.Log("already downloaded image urls");
                 *   OnUnityEntered();
                 *   continue;
                 * }
                 * //todo
                 * downloadedUrls.Add(collection.arList[i].targetImageUrl);
                 * urlDownloadedEvent?.Invoke(collection.arList[i]);*/
                GameObject.FindObjectOfType <DynamicImageTarget>().DownloadImageFromServerFunc(collection.arList[i]);
                print("image url " + i + collection.arList[i].targetImageUrl);
                // ensure projectid  and advertisements ids are not null and send to analytics with onArscreenopen event
                //if (collection.arList[i].project_id != null)
                //{
                //    IdManager.Instance.projectId = collection.arList[i].project_id;
                //    Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "project_id", collection.arList[i].project_id);
                //    Debug.Log("Project_id " + collection.arList[i].project_id);
                //}
                //if(collection.arList[i].advertisement_id != null)
                // {
                //     IdManager.Instance.advertisementId = collection.arList[i].advertisement_id;
                //     Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "advertisement_id", collection.arList[i].advertisement_id);
                //     Debug.Log("Advertisement_id " + collection.arList[i].advertisement_id);
                // }
                //if (collection.arList[i].promotion_id != null)
                //{
                //    IdManager.Instance.PromotionId = collection.arList[i].promotion_id;
                //    Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "advertisement_id", collection.arList[i].promotion_id);
                //    Debug.Log("Promotion_id " + collection.arList[i].promotion_id);
                //}
                print("video url " + i + collection.arList[i].targetVideoUrl);
            }
        }
Esempio n. 3
0
        public void JsonFromNative(string s)
        {
            print("got json" + s);

            Debug.Log("got info from native" + s);


            ImageVideoTemplateCollection collection = new ImageVideoTemplateCollection();

            collection = JsonUtility.FromJson <ImageVideoTemplateCollection>(s);
            Debug.Log(collection);
            for (int i = 0; i < collection.arList.Length; i++)
            {
                if (downloadedUrls.Contains(collection.arList[i].targetImageUrl))
                {
                    Debug.Log("already downloaded image urls");
                    //OnUnityEntered();
                    continue;
                }
                //todo
                downloadedUrls.Add(collection.arList[i].targetImageUrl);
                GameObject.FindObjectOfType <DynamicImageTarget>().OnUrlRetrieved(collection.arList[i]);
                //urlDownloadedEvent?.Invoke(collection.arList[i]);

                //print("image url " + i + collection.arList[i].targetImageUrl);
                //// ensure projectid  and advertisements ids are not null and send to analytics with onArscreenopen event
                //if (collection.arList[i].project_id != null)
                //{
                //    IdManager.Instance.projectId = collection.arList[i].project_id;
                //    Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "project_id", collection.arList[i].project_id);
                //    Debug.Log("Project_id " + collection.arList[i].project_id);
                //}
                //if (collection.arList[i].advertisement_id != null)
                //{
                //    IdManager.Instance.advertisementId = collection.arList[i].advertisement_id;
                //    Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "advertisement_id", collection.arList[i].advertisement_id);
                //    Debug.Log("Advertisement_id " + collection.arList[i].advertisement_id);
                //}
                //if (collection.arList[i].promotion_id != null)
                //{
                //    IdManager.Instance.PromotionId = collection.arList[i].promotion_id;
                //    Firebase.Analytics.FirebaseAnalytics.LogEvent("AR_ScreenOpen", "advertisement_id", collection.arList[i].promotion_id);
                //    Debug.Log("Promotion_id " + collection.arList[i].promotion_id);
                //}
                print("video url " + i + collection.arList[i].targetVideoUrl);
            }
        }