Пример #1
0
    public void OnClickBtnFromJson()
    {
        string tJson = @"
            {
                ""mName"" : ""My"",
                ""mStringList"":
                [
                    ""weapon_0"",""weapon_777""
                ],
                ""mLevel"":10,
                ""mExp"":12345
            }
        ";


        CMyTestInfo tInfo = JsonUtility.FromJson <CMyTestInfo>(tJson);

        Debug.Log(tInfo.mName);
        Debug.Log(tInfo.mLevel);
        Debug.Log(tInfo.mExp);

        foreach (var tElement in tInfo.mStringList)
        {
            Debug.Log(tElement);
        }
    }
Пример #2
0
    public void OnClickBtnOverwriteFromJson()
    {
        string tJson = @"
            {
                ""mName"" : ""데이터"",
                ""mStringList"":
                [
                    ""weapon_0"",""weapon_777""
                ],
                ""mLevel"":10,
                ""mExp"":12345
            }
        ";


        CMyTestInfo tInfo = JsonUtility.FromJson <CMyTestInfo>(tJson);

        Debug.Log(tInfo.mName);
        Debug.Log(tInfo.mLevel);
        Debug.Log(tInfo.mExp);
        foreach (var tElement in tInfo.mStringList)
        {
            Debug.Log(tElement);
        }
        Debug.Log("======================");


        string tJson_0 = @"
            {
                ""mName"" : ""알베르토"",
                ""mLevel"":789,
                ""mExp"":564363,
                ""mStringList"":
                [
                    ""weapon_999"",""weapon_123""
                ]
            }
        ";

        JsonUtility.FromJsonOverwrite(tJson_0, tInfo);

        Debug.Log(tInfo.mName);
        Debug.Log(tInfo.mLevel);
        Debug.Log(tInfo.mExp);
        foreach (var tElement in tInfo.mStringList)
        {
            Debug.Log(tElement);
        }
    }
Пример #3
0
    public void OnClickBtnToJson()
    {
        CMyTestInfo tInfo = new CMyTestInfo();

        tInfo.mName       = "알베르토";
        tInfo.mLevel      = 999;
        tInfo.mExp        = 12345;
        tInfo.mStringList = new List <string>();
        tInfo.mStringList.Add("weapon_777");
        tInfo.mStringList.Add("weapon_888");

        string tJson = "";

        tJson = JsonUtility.ToJson(tInfo);

        Debug.Log("<color='red'>" + tJson + "</color>");
    }