private void OnMainFileDownloadSuccess(byte[] pBytes)
    {
        string json = Encoding.UTF8.GetString(pBytes);

        Debug.Log(json);
        MainJson mainJson = JsonUtility.FromJson <MainJson>(json);

        Application.targetFrameRate = AppConst.s_FrameRate = mainJson.frameRate;
        AppConst.s_IsDebug          = mainJson.isDebug;
        AppConst.s_Host             = mainJson.host;
        AppConst.s_AppVersion       = AppVersion.Create(mainJson.version);
        //资源版本取PlayerPrefs存的
        if (PlayerPrefs.HasKey("ResVersion"))
        {
            AppConst.s_AppVersion.d = PlayerPrefs.GetInt("ResVersion");
        }

        foreach (MainTextJson mainTextJson in mainJson.texts)
        {
            GameMain.Instance.m_Texts[mainTextJson.id] = mainTextJson.text;
        }

        //下载远程Version配置
        string path = AppConst.GetRemoteURL("Version.json");

        DownloadManager.Instance.DownloadFileAsync(path, OnVersionFileDownloadSuccess, pProgressCallback: OnVersionFileDowloadProgress);
    }
    // Start is called before the first frame update
    void Start()
    {
        MyObjects = GameObject.FindGameObjectsWithTag("MyObjects");
        var jsonTextFile = Resources.Load("JsonData");

        print(jsonTextFile);
        mainJson = JsonUtility.FromJson <MainJson>(jsonTextFile.ToString());
        AssignJsonDataToObjects();
    }
예제 #3
0
        static void Main()
        {
            Application.Current.Use(new HtmlFromJsonProvider());
            Application.Current.Use(new PartialToStandaloneHtmlProvider());

            Handle.GET("/Yuri", () =>
            {
                return(Db.Scope(() =>
                {
                    var corporations = Db.SQL <Corporation>("SELECT c FROM Yuri.Models.Corporation c");
                    var json = new MainJson()
                    {
                        Corporations = corporations
                    };
                    if (Session.Current == null)
                    {
                        Session.Current = new Session(SessionOptions.PatchVersioning);
                    }

                    json.Session = Session.Current;
                    return json;
                }));
            });

            Handle.GET("/Yuri/franchise/{?}", (string ObjectID, Request request) =>
            {
                return(Db.Scope(() =>
                {
                    var office = Db.SQL <FranchiseOffice>("SELECT fo FROM Yuri.Models.FranchiseOffice fo WHERE fo.ObjectID = ?", ObjectID).First;
                    var json = new FranchiseOfficeJson()
                    {
                        Data = office
                    };
                    if (Session.Current == null)
                    {
                        Session.Current = new Session(SessionOptions.PatchVersioning);
                    }

                    json.Session = Session.Current;
                    return json;
                }));
            });
        }
 //convert the JSON  into an object using JsonUtility.FromJson:
 void ParseJsonData(string JsonString)
 {
     mainJson = JsonUtility.FromJson <MainJson>(JsonString);
     AssignJsonDataToObjects();
 }