// public List <TransitionInfo> LoadAnimation(GameMainManager.Root rootinfo = GameMainManager.Root.Main) { //戻り値を設定 List <TransitionInfo> date = new List <TransitionInfo> (); // Json FileNameを列挙体から取得 string info; /* if (rootinfo != GameMainManager.Root.Main) { * info = rootinfo.ToString (); * } * else { * * info = rootinfo.ToString(); * * }*/ TextAsset textAsset = Resources.Load(rootinfo.ToString()) as TextAsset; string jsonText = textAsset.text; JsonNode json = JsonNode.Parse(jsonText); Debug.Log(jsonText); for (int i = 0; i < 20; i++) { long animation = json["info"][i]["animation"].Get <long> (); long state = json["info"][i]["state"].Get <long> (); double time = json["info"][i]["time"].Get <double> (); if (time == -1) { break; } //情報追加 date.Add(new TransitionInfo((float)time, (CharacterAnimator.Animation)animation, (CharacterAnimator.State)state)); } return(date); }
//アニメーションセーブ public void SavedAnimation(GameMainManager.Root rootinfo = GameMainManager.Root.Main) { //書き込み.//////// //既存チェッカー var _strage_path = (Application.dataPath + JsonPath); if (!Directory.Exists(_strage_path)) { //なかったら作る。 Directory.CreateDirectory(_strage_path); } FileName = ("/" + rootinfo.ToString() + ".json"); Debug.Log("dede" + FileName); var json_text = File.ReadAllText(Application.dataPath + JsonPath + FileName); var json_test = Json.Deserialize(json_text) as Dictionary <string, object>; //ルート指定があった場合その場所に保存 List <object> info; /* if (rootinfo != GameMainManager.Root.Main) * { * info = json_test [rootinfo.ToString()] as List<object>; * } * else*/ { info = json_test ["info"] as List <object>; } for (int i = 0; i < _transition_index.Count - 1; i++) { var save_date = info[i] as Dictionary <string, object>; save_date ["animation"] = (double)_transition_index[i]._Animation; save_date ["state"] = (double)_transition_index[i]._State; save_date ["time"] = (double)_transition_index[i]._TransitionTime; } File.WriteAllText(Application.dataPath + JsonPath + FileName, Json.Serialize(json_test)); }