PrintAsync() public method

public PrintAsync ( bool pretty = false ) : IEnumerable
pretty bool
return IEnumerable
Beispiel #1
0
    void CollectData()
    {
        Debug.Log(ssss);
        JSONObject js = new JSONObject(ssss);

        IEnumerable <string> ss = js.PrintAsync();

        using (var sequenceEnum = ss.GetEnumerator())
        {
            while (sequenceEnum.MoveNext())
            {
                // Do something with sequenceEnum.Current.
                if (sequenceEnum.Current != null)
                {
                    string currentWord = sequenceEnum.Current;
                    currentWord = currentWord.Replace("[", "");
                    currentWord = currentWord.Replace("]", "");
                    currentWord = currentWord.Replace("\"", "");

                    foreach (string temp in currentWord.Split(','))
                    {
                        words.Add(temp);
                    }
                }
            }
        }
    }
    IEnumerator getLeaderBoard()
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Get("http://server.wordsfight.com/leader-board"))
        {
            // Request and wait for the desired page.
            yield return(webRequest.SendWebRequest());

            if (webRequest.isNetworkError)
            {
                Debug.Log(webRequest.error);
            }
            else
            {
                //Debug.Log(webRequest.downloadHandler.text);
                try
                {
                    JSONObject js = new JSONObject(webRequest.downloadHandler.text);

                    foreach (string s in js.PrintAsync())
                    {
                        string ss = s.Replace("{", "");
                        ss = ss.Replace("}", "");
                        ss = ss.Replace("\"", "");
                        string[] sss = ss.Split(',');

                        foreach (string ssx in sss)
                        {
                            string[] locals = ssx.Split(':');
                            //Debug.Log(locals[0] + " : " + locals[1]);

                            GameObject g = Instantiate(person_leaderBoard, personContainer.transform);
                            g.transform.GetChild(0).GetComponent <Text>().text = locals[0]; //name
                            g.transform.GetChild(1).GetComponent <Text>().text = locals[1]; //score
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.Log("NO USER");
                }
            }
        }
    }
Beispiel #3
0
    IEnumerator loadFromResourcesFolder()
    {
        //Request data to be loaded
        ResourceRequest loadAsync = Resources.LoadAsync("eng_words", typeof(TextAsset));

        //Wait till we are done loading
        while (!loadAsync.isDone)
        {
            Debug.Log("Load Progress: " + loadAsync.progress);
            yield return(null);
        }

        //Get the loaded data
        TextAsset tt = loadAsync.asset as TextAsset;

        Debug.LogError(tt.text);
        JSONObject js = new JSONObject(tt.text);

        IEnumerable <string> ss = js.PrintAsync();

        using (var sequenceEnum = ss.GetEnumerator())
        {
            while (sequenceEnum.MoveNext())
            {
                // Do something with sequenceEnum.Current.
                if (sequenceEnum.Current != null)
                {
                    string currentWord = sequenceEnum.Current;
                    currentWord = currentWord.Replace("[", "");
                    currentWord = currentWord.Replace("]", "");
                    currentWord = currentWord.Replace("\"", "");

                    foreach (string temp in currentWord.Split(','))
                    {
                        words.Add(temp);
                        Debug.Log(temp);
                    }
                }
            }
        }
    }