public ChordObject DouplicateChordObject(ChordObject chordObj, List <ChordObject> chordObjects) { // 0. Refs var fields = Player.inst.curFieldSet; var ID = chordObj.fieldID; var parent = MeshRef.inst.recordObj_parent; var material = MeshRef.inst.recordObjs_mat[chordObj.trackLayer]; var pos = Recorder.inst.NextLoopPosition(chordObj.sequencer, chordObj.start); var layer = 8; var visible = true; var collider = true; var tag = MeshRef.inst.chordObjTag; // 1. Instantiate & scale! var newObj = MeshCreation.CreateLaneSurface(fields, ID, "ChordObject", parent, material, visible, collider, tag, 1f, layer).gameObject; newObj.transform.localScale = chordObj.obj.transform.localScale; var douplicateObj = ChordObject.Create(newObj, null, pos, ID, chordObj.notes, chordObj.sequencer, chordObj.trackLayer, chordObj.start, chordObj.end, chordObj.loopStart, chordObj.loopEnd_extended); // 2. Set data chordObj.douplicate = douplicateObj; chordObj.hasRespawned = true; // 3. Add to list chordObjects.Add(douplicateObj); return(douplicateObj); }
// ------------------------------ Public functions ------------------------------ /// <summary> /// Instantiate 2 lane surfaces (current chord, looped chord) from recording-data and keep scaling it by a coroutine upwards from zero until stopped. Writes into recording (!). /// </summary> /// <param name="recording">Recording data.</param> /// <param name="chordObjects">List to add the new chord objects.</param> public void CreateChordObjectTwice(Recording recording, List <ChordObject>[] chordObjects, int trackLayer) { // 0. Refs var fields = Player.inst.curFieldSet; var ID = recording.fieldID; var parent = MeshRef.inst.recordObj_parent; var material = MeshRef.inst.recordObjs_mat[trackLayer]; var pos1 = Player.inst.transform.position; var pos2 = Recorder.inst.NextLoopPosition(recording.sequencer, recording.start); var layer1 = LayerMask.NameToLayer(MeshRef.inst.highlightSurfaces_layer); var renderQueue1 = MeshRef.inst.highlightSurfaces_renderQueue + 1; var layer2 = LayerMask.NameToLayer(MeshRef.inst.recordLayer); //var layer = 8; var collider = true; var visible = true; var tag = MeshRef.inst.chordObjTag; // 1. Instantiate var obj1 = MeshCreation.CreateLaneSurface(fields, ID, "ChordObject", parent, material, visible, collider, tag, 1f, layer1, renderQueue1).gameObject; var obj2 = MeshCreation.CreateLaneSurface(fields, ID, "ChordObject", parent, material, visible, collider, tag, 1f, layer2).gameObject; var recordObject2 = ChordObject.Create(obj2, null, pos2, ID, recording.notes, recording.sequencer, trackLayer, recording.start, recording.end, recording.loopStart, recording.loopEnd_extended); var recordObject1 = ChordObject.Create(obj1, recordObject2, pos1, ID, recording.notes, recording.sequencer, trackLayer, recording.start, recording.end, recording.loopStart, recording.loopEnd_extended); recordObject1.hasRespawned = true; // 2. Add to list chordObjects[trackLayer].Add(recordObject1); chordObjects[trackLayer].Add(recordObject2); // 3. Edit recording / Start scaling recording.obj = recordObject1; // Nur für scaling-coroutine recording.loopObj = recordObject2; // Nur für scaling-coroutine recording.scaleRoutine = StartCoroutine(ScaleChordObject(recordObject1, recordObject2)); }