123456789101112131415161718192021222324252627282930313233343536373839 |
- using Newtonsoft.Json;
- using NUnit.Framework;
- using System.Collections.Generic;
- using UnityEngine;
- public class SoundTrackManager
- {
- public string name { set; get; }
- public string resource { set; get; }
- public string description { set; get; }
- public int speed { set; get; } = 100;
- public int length { set; get; } = 0;
- public List<SoundAction> soundAction { set; get; } = new List<SoundAction>();
- public void ImportFromJson(string json)
- {
- var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
- speed = int.Parse(data["speed"].ToString());
- name = data["name"].ToString();
- resource = data["resource"].ToString();
- description = data["description"].ToString();
- length = int.Parse(data["length"].ToString());
- soundAction.Clear();
- SoundAction[] actions = JsonConvert.DeserializeObject<SoundAction[]>(data["action points"].ToString());
- foreach (var action in actions)
- {
- soundAction.Add(action);
- }
- }
- }
- public class SoundAction
- {
- public float time { set; get; } = 0f;
- public string action { set; get; } = "";
- public bool isTapped = false; // 表示当前这个音乐动作是否被播放过
- public bool isActive = false; // 表示当前这个音乐动作是否正在场景中激活
- }
|