void CtrlNote() { if (Event.current.type == EventType.KeyUp) { if (Event.current.keyCode == KeyCode.Delete) { currentPart.RemoveSelected(); currentPart.CleanSelected(); } } if (music.IsPlaying) { selectStart.x = selectStart.y = -1; selectEnd = selectStart; return; } if (selectStart.x >= 0 && selectStart.y >= 0 && selectStart.y < MusicalNote.Notes.Length) { if (currentPart.Selected.Length == 0) { if (Event.current.type == EventType.MouseUp) { if (Event.current.shift) { if (Event.current.button == 0) { currentPart.Select(selectStart.y, selectEnd.y, selectStart.x * sizeA, selectEnd.x * sizeA); } } else if (Event.current.control) { if (Event.current.button == 0) { playTime = selectStart.x * sizeA; } } else { if (Event.current.button == 0) { if (testClip) { DestroyImmediate(testClip); testClip = null; } if (testSource && testSource.gameObject) { DestroyImmediate(testSource.gameObject); } currentPart.AddNote(selectStart.y, selectStart.x * sizeA, (selectEnd.x - selectStart.x + 1) * sizeA); SoundClip soundClip = new SoundClip(currentPart.Timbre, 4000, MusicalNote.NoteHz[selectStart.y], MusicalNote.NoteHz[selectStart.y], 0, 0.5f, true); testClip = AudioClip.Create("test", soundClip.Data.Length, 1, 4000, false); testClip.SetData(soundClip.Data, 0); GameObject test = new GameObject(); test.name = "audio clip on shot"; testSource = test.AddComponent <AudioSource>(); testSource.clip = testClip; testSource.Play(); } else if (Event.current.button == 1) { currentPart.Select(selectStart.y, selectStart.x * sizeA); currentPart.RemoveSelected(); currentPart.CleanSelected(); } music.UpdateParts(); } selectStart.x = selectStart.y = -1; selectEnd = selectStart; } } else { if (Event.current.type == EventType.MouseUp) { if (selectEnd == selectStart) { currentPart.CleanSelected(); } else { currentPart.MoveSelected(selectStart.x * sizeA, selectStart.y, selectEnd.x * sizeA, selectEnd.y); selectStart.x = selectStart.y = -1; selectEnd = selectStart; music.UpdateParts(); } } } } }