I am making a 2D piano player game. I am mostly done, but I am new to Unity and programming in C#, and I am not sure how to do the next part. What do I do to make it so that when I press the record button, it records the notes and then plays it back when the play button is pressed? My script is down below. Thank you in advance for your help
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NotePlay : MonoBehaviour {
Animator anim;
public AudioClip noteA;
public AudioClip noteB;
public AudioClip noteC;
public AudioClip noteD;
public AudioClip noteE;
public AudioClip noteF;
public AudioClip noteG;
public AudioSource audio;
public string[] store;
private KeyCode lastHitKey;
// Use this for initialization
void Start() {
anim = gameObject.GetComponent<Animator>();
audio = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update() {
if (Input.GetKeyDown(KeyCode.A)) {
anim.SetTrigger("A");
audio.PlayOneShot(noteA);
}
if (Input.GetKeyDown(KeyCode.B)) {
anim.SetTrigger("B");
audio.PlayOneShot(noteB);
}
if (Input.GetKeyDown(KeyCode.C)) {
audio.PlayOneShot(noteC);
anim.SetTrigger("C");
}
else if (Input.GetKeyDown(KeyCode.D)) {
anim.SetTrigger("D");
audio.PlayOneShot(noteD);
}
else if (Input.GetKeyDown(KeyCode.E)) {
anim.SetTrigger("E");
audio.PlayOneShot(noteE);
}
if (Input.GetKeyDown(KeyCode.F)) {
anim.SetTrigger("F");
audio.PlayOneShot(noteF);
}
if (Input.GetKeyDown(KeyCode.G)) {
anim.SetTrigger("G");
audio.PlayOneShot(noteG);
}
}
}