/// <summary> /// make a new recording /// </summary> /// <param name="name"></param> public void createRecording(string name) { ReplayFileTarget target = ReplayManager.Target as ReplayFileTarget; // Set the location/name of the replay file to load target.FileOutputName = name + ".replay"; Debug.Log(name); //add it to the dictionary and save to a file. GetComponent <micRecorder>().StartRecording(name); RecordingDictionaryClass.addRecording(name, name + ".replay", name + ".wav"); RecordingDictionaryClass.SaveDictionary(); ReplayManager.BeginRecording(); Debug.Log("Recording"); }
/// <summary> /// loads the dictionary from the csv /// </summary> public static void load() { try { StreamReader sr = new StreamReader(Application.streamingAssetsPath + "/Dictionary.csv"); //read through the file line by line each line is an entery in the dic while (!sr.EndOfStream) { string line = sr.ReadLine(); string[] input = line.Split(','); RecordingDictionaryClass.addRecording(input[0], input[1], input[2]); } sr.Close(); } catch { Debug.Log("file dose not exist"); } }
/// <summary> /// build the menue for selecting from saved recordings /// </summary> public void Build() { //refrence to the dictionary data structure if (RecordingDictionaryClass.RecordingDictionary == null) { RecordingDictionaryClass.Init(); //RecordingDictionaryClass.load(); } var dic = RecordingDictionaryClass.RecordingDictionary; int offset = 0; //for each entery create a button set its text to the key and its on press event foreach (KeyValuePair <string, string> s in dic) { GameObject b = Instantiate(Button, gameObject.transform); b.transform.position = new Vector3(transform.position.x, 130 - offset, transform.position.z); offset -= 40; b.GetComponent <Button>().onClick.AddListener(delegate { buttonPress(s.Key); }); b.transform.GetChild(0).gameObject.GetComponent <Text>().text = s.Key; } }
// Start is called before the first frame update void Start() { DontDestroyOnLoad(this); RecordingDictionaryClass.Init(); }
// Start is called before the first frame update void Start() { controler = ReplayControler.instance; RecordingDictionaryClass.Init(); }