実現したいこと
unityでリズムゲームを作っています。
譜面データの作成でsetchiさんのNotesEditerを利用して、下記のデータを作ったのですが、読み込み方がわからなくて困っています。
譜面データの場所はC:\Users\ ~ 略 ~ \プロジェクト名\data\notes.json です。
どなたか教えていただけませんか?
####譜面データ
json
1{ 2 "name": "name", 3 "maxBlock": 6, 4 "BPM": 260, 5 "offset": 55000, 6 "notes": [ 7 { 8 "LPB": 4, 9 "num": 0, 10 "block": 0, 11 "type": 1, 12 "notes": [] 13 }, 14 { 15 "LPB": 4, 16 "num": 0, 17 "block": 2, 18 "type": 1, 19 "notes": [] 20 }, 21 { 22 "LPB": 4, 23 "num": 4, 24 "block": 3, 25 "type": 1, 26 "notes": [] 27 }, 28 { 29 "LPB": 4, 30 "num": 8, 31 "block": 0, 32 "type": 2, 33 "notes": [ 34 { 35 "LPB": 4, 36 "num": 12, 37 "block": 1, 38 "type": 2, 39 "notes": [] 40 }, 41 { 42 "LPB": 4, 43 "num": 16, 44 "block": 1, 45 "type": 2, 46 "notes": [] 47 } 48 ] 49 }, 50 { 51 "LPB": 4, 52 "num": 8, 53 "block": 5, 54 "type": 2, 55 "notes": [ 56 { 57 "LPB": 4, 58 "num": 12, 59 "block": 4, 60 "type": 2, 61 "notes": [] 62 }, 63 { 64 "LPB": 4, 65 "num": 16, 66 "block": 4, 67 "type": 2, 68 "notes": [] 69 } 70 ] 71 }, 72 { 73 "LPB": 4, 74 "num": 20, 75 "block": 2, 76 "type": 1, 77 "notes": [] 78 }, 79 { 80 "LPB": 4, 81 "num": 22, 82 "block": 3, 83 "type": 1, 84 "notes": [] 85 }, 86 { 87 "LPB": 4, 88 "num": 24, 89 "block": 1, 90 "type": 1, 91 "notes": [] 92 }, 93 { 94 "LPB": 4, 95 "num": 26, 96 "block": 4, 97 "type": 1, 98 "notes": [] 99 }, 100 { 101 "LPB": 4, 102 "num": 28, 103 "block": 0, 104 "type": 1, 105 "notes": [] 106 }, 107 { 108 "LPB": 4, 109 "num": 30, 110 "block": 5, 111 "type": 1, 112 "notes": [] 113 }, 114 { 115 "LPB": 4, 116 "num": 32, 117 "block": 0, 118 "type": 1, 119 "notes": [] 120 }, 121 { 122 "LPB": 4, 123 "num": 32, 124 "block": 5, 125 "type": 2, 126 "notes": [ 127 { 128 "LPB": 4, 129 "num": 40, 130 "block": 5, 131 "type": 2, 132 "notes": [] 133 }, 134 { 135 "LPB": 4, 136 "num": 44, 137 "block": 4, 138 "type": 2, 139 "notes": [] 140 } 141 ] 142 }, 143 { 144 "LPB": 4, 145 "num": 36, 146 "block": 0, 147 "type": 2, 148 "notes": [ 149 { 150 "LPB": 4, 151 "num": 40, 152 "block": 2, 153 "type": 2, 154 "notes": [] 155 }, 156 { 157 "LPB": 4, 158 "num": 44, 159 "block": 0, 160 "type": 2, 161 "notes": [] 162 } 163 ] 164 } 165 ] 166}
####読み込むためのソースコード
C#
1using UnityEngine; 2using System; 3using System.IO; 4 5[Serializable] 6public class InputJson 7{ 8 public int BPM; 9 public int offset; 10 public Notesdata[] notes; 11 12} 13[Serializable] 14public class Notesdata 15{ 16 public int LPB; 17 public int num; 18 public int block; 19 public int type; 20} 21 22public class GameController : MonoBehaviour { 23 private static string path; 24 void Start() 25 { 26 path = "/../data/notes.json"; 27 var info = new FileInfo(Application.dataPath + path); 28 var reader = new StreamReader(info.OpenRead()); 29 var json = reader.ReadToEnd(); 30 var data = JsonUtility.FromJson<InputJson>(json); 31 32 // 33 //ここから先はどう書けばいいのかわからない 34 // 35 36 } 37}
試したこと
ソースコードの参考にしたサイト
いろいろなサイトを徘徊してもオブジェクトやらネストやらよくわかりませんでした。
補足
unity 2019.2.10f1
Visual studio 2019
NotesEditer配布場所
あなたの回答
tips
プレビュー