前提・実現したいこと
NoteEditorを使用して以下のような譜面を作成し、読み込む所までは完成しました。
json
1test.json 2{"name":"test", 3"maxBlock":5, 4"BPM":120, 5"offset":0, 6"notes":[ 7{"LPB":4,"num":4,"block":0,"type":1,"notes":[]}, 8{"LPB":4,"num":5,"block":1,"type":1,"notes":[]}, 9{"LPB":4,"num":6,"block":2,"type":1,"notes":[]}, 10{"LPB":4,"num":7,"block":3,"type":1,"notes":[]}, 11{"LPB":4,"num":8,"block":4,"type":1,"notes":[]}]}
しかし、以下の写真のように一部ノーツが正しく生成されませんでした。
こんな感じにBPMを上限まで上げても正しく生成されなかったです。
json
1{"name":"test", 2"maxBlock":5, 3"BPM":320, 4"offset":0, 5"notes":[ 6{"LPB":4,"num":4,"block":0,"type":1,"notes":[]}, 7{"LPB":4,"num":5,"block":1,"type":1,"notes":[]}, 8{"LPB":4,"num":6,"block":2,"type":1,"notes":[]}, 9{"LPB":4,"num":7,"block":3,"type":1,"notes":[]}, 10{"LPB":4,"num":8,"block":4,"type":1,"notes":[]}]}
もうお手上げ状態です。どなたか解決策をお願いします。
該当のソースコード
c#
1 2using System; 3using UnityEngine; 4 5 6[Serializable] 7public class Humen 8{ 9 public string name; 10 public int maxBlock; 11 public int BPM; 12 public int offset; 13 public Notes[] notes; 14 15} 16[Serializable] 17public class Notes 18{ 19 public int num; 20 public int block; 21} 22 23 24public class JsonUtil : MonoBehaviour 25{ 26 27 int note; 28 float TimeCount = 0.01f; 29 public GameObject notepref; 30 public GameObject exnotepref; 31 void Start() 32 { 33 34 35 string inputString = Resources.Load<TextAsset>("test").ToString(); 36 37 Humen inputJson = JsonUtility.FromJson<Humen>(inputString); 38 39 40 41 for (int a = 0; a < 300; a++) 42 { 43 44 45 46 Instantiate(notepref, new Vector3(-4 + inputJson.notes[a].block * 2f, 0f, 40 + inputJson.notes[a].num * 60 / inputJson.BPM * 10f), Quaternion.identity); 47 48 Debug.Log("Num:" + inputJson.notes[a].num + " Block:" + inputJson.notes[a].block + " A:"+a); 49 50 51 } 52 53 54 55 } 56 void Update() 57 { 58 59 } 60 } 61 62}
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class note : MonoBehaviour 6{ 7 8 void Start() 9 { 10 transform.Rotate(new Vector3(90, 0, 0)); 11 } 12 13 14 void FixedUpdate() 15 { 16 17 18 19 Transform myTransform = this.transform; 20 21 22 Vector3 pos = myTransform.position; 23 24 pos.z -= 0.8f; 25 26 myTransform.position = pos; 27 28} 29}
回答1件
あなたの回答
tips
プレビュー