如何将我的void update转换变量导出到json文件

时间:2016-04-24 16:49:31

标签: c# json parsing rotation

using UnityEngine;
using System.Collections;
using LitJson;
using System.IO;
public class Rotator : MonoBehaviour {
public Character player = new Character(0, 0, 0, 0,0);
    // Use this for initialization
    JsonData playerJson;

我希望能够从我将添加到我的游戏中的旋转障碍物的json文件中更改值但我无法找到一种方法来执行此操作,因为我对json文件非常新,所以我怎么能在void update中添加公共类字符的值,或者至少是解析旋转变量的方法。

更详细,更简单的话,void更新应该像你在里面看到的值一样旋转对象,但是我想将这些值导出到json文件,并且它们可以在json文件中变换,所以你可以请帮帮我?非常重要的

void Start()
    {
        playerJson = JsonMapper.ToJson(player);
        File.WriteAllText(Application.dataPath + "/Player.json", playerJson.ToString());
    }
 public int Xaxis;
    public int Yaxis;
    public int Zaxis;
    public int speed;
 void Update()
    {
        transform.Rotate(new Vector3(Xaxis, Yaxis, Zaxis) * Time.deltaTime *speed);
    }
public class Character
    {
        public int id;
      public int Xaxis;
        public int Yaxis;
        public int Zaxis;
        public int speed;
 public Character(int id, int Xaxis, int Yaxis, int Zaxis, int speed)
        {
            this.id = id;
            this.Xaxis = Xaxis;
            this.Yaxis = Yaxis;
            this.Zaxis = Zaxis;
            this.speed = speed;

        }
    }

}

0 个答案:

没有答案