private void AddNewMelody(int targetIndex = -1) { GameObject newDiagram = Instantiate <GameObject>(MelodyDiagramTemplate, ScrollContainer); newDiagram.transform.SetSiblingIndex(targetIndex >= 0 ? targetIndex : ScrollContainer.childCount - 3); MelodyDiagram diagram = newDiagram.GetComponent <MelodyDiagram>(); diagram.Initialize(OnMelodyRemoved, OnMelodyDuplicated, AddNewElement, MoveElement); melodies.Add(diagram); }
private void OnMelodyDuplicated(MelodyDiagram diagram) { AddNewMelody(diagram.CurrentMelody); }
private void OnMelodyRemoved(MelodyDiagram diagram) { melodies.Remove(diagram); }