예제 #1
0
    //----------------------------------------------------------------------
    IEnumerator IGetData()
    {
        // 从网络拉取
        if (true)
        {
            WWW www = new WWW(NetConfig.s_qiniuDownloadUrl + "code.json");
            yield return(www);//等待Web服务器的反应

            // 错误
            if (www.error != null)
            {
                Debug.Log(www.error);
                yield return(null);
            }

            SceneLogScript.setLog("0");
            //Debug.Log(www.text);
            SceneLogScript.setLog(www.text);
            Entity_code.getInstance().init(www.text);
        }
        // 从本地拉取
        else
        {
            yield return(null);

            StreamReader sr       = new StreamReader("Assets\\Resources\\Files\\code.json", System.Text.Encoding.GetEncoding("utf-8"));
            string       jsonData = sr.ReadToEnd().ToString();
            sr.Close();

            //Debug.Log(jsonData);
            Entity_code.getInstance().init(jsonData);
        }
    }
예제 #2
0
    public static Entity_code getInstance()
    {
        if (s_entity_code == null)
        {
            s_entity_code = new Entity_code();
        }

        return(s_entity_code);
    }