File tree 3 files changed +7
-1
lines changed
3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ namespace MidiAnim
12
12
[ ScriptedImporter ( 1 , "midianim" ) ]
13
13
class MidiAnimImporter : ScriptedImporter
14
14
{
15
+ [ SerializeField ] int _trackIndex = 0 ;
15
16
[ SerializeField ] float _bpm = 120 ;
16
17
[ SerializeField ] bool _gateEasing = false ;
17
18
[ SerializeField ] float _attackTime = 0.1f ;
@@ -20,7 +21,7 @@ class MidiAnimImporter : ScriptedImporter
20
21
public override void OnImportAsset ( AssetImportContext context )
21
22
{
22
23
var song = MidiFileLoader . Load ( File . ReadAllBytes ( context . assetPath ) ) ;
23
- var seq = new MidiTrackSequencer ( song . tracks [ 0 ] , song . division , _bpm ) ;
24
+ var seq = new MidiTrackSequencer ( song . tracks [ _trackIndex ] , song . division , _bpm ) ;
24
25
25
26
var clip = new MidiClip ( _bpm ) ;
26
27
if ( _gateEasing ) clip . EnableEasing ( _attackTime , _releaseTime ) ;
Original file line number Diff line number Diff line change @@ -12,13 +12,15 @@ namespace MidiAnim
12
12
[ CustomEditor ( typeof ( MidiAnimImporter ) ) ]
13
13
class MidiAnimImporterEditor : ScriptedImporterEditor
14
14
{
15
+ SerializedProperty _trackIndex ;
15
16
SerializedProperty _bpm ;
16
17
SerializedProperty _gateEasing ;
17
18
SerializedProperty _attackTime ;
18
19
SerializedProperty _releaseTime ;
19
20
20
21
static class Styles
21
22
{
23
+ public static readonly GUIContent TrackIndex = new GUIContent ( "Track Index" ) ;
22
24
public static readonly GUIContent BPM = new GUIContent ( "BPM" ) ;
23
25
}
24
26
@@ -29,6 +31,7 @@ public override void OnEnable()
29
31
{
30
32
base . OnEnable ( ) ;
31
33
34
+ _trackIndex = serializedObject . FindProperty ( "_trackIndex" ) ;
32
35
_bpm = serializedObject . FindProperty ( "_bpm" ) ;
33
36
_gateEasing = serializedObject . FindProperty ( "_gateEasing" ) ;
34
37
_attackTime = serializedObject . FindProperty ( "_attackTime" ) ;
@@ -37,6 +40,7 @@ public override void OnEnable()
37
40
38
41
public override void OnInspectorGUI ( )
39
42
{
43
+ EditorGUILayout . PropertyField ( _trackIndex , Styles . TrackIndex ) ;
40
44
EditorGUILayout . PropertyField ( _bpm , Styles . BPM ) ;
41
45
EditorGUILayout . PropertyField ( _gateEasing ) ;
42
46
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ There are a few settings in the inspector.
32
32
33
33
![ inspector] ( https://i.imgur.com/HDWZgX7.png )
34
34
35
+ - ** Track Index** - The MIDI file track index that will be imported.
35
36
- ** BPM** - The importer doesn't support the BPM meta information, so that the
36
37
BPM has to be set manually.
37
38
- ** Gate Easing** - When enabled, the note curves are to be smoothed by adding
You can’t perform that action at this time.
0 commit comments