//Write paths data private bool WritePaths(bool writeComment) { if (runtimePaths.Count <= 0 && writeMode == WriteModes.Append) { return(false); } foreach (KeyValuePair <string, Recordable.Runtime> pair in runtimePaths) { if (pair.Value.Data.Count <= 0) { continue; } Recordable.Data data = pair.Value.Data[pair.Value.Data.Count - 1]; data.isBreak = true; } string path = Utils.GetPathsFilePath(); StreamWriter file; if (writeMode == WriteModes.Overwrite) { file = new StreamWriter(path); } else { file = new StreamWriter(path, true); } using (file) { if (writeComment) { WriteComment(file); } foreach (KeyValuePair <string, Recordable.Runtime> pair in runtimePaths) { if (pair.Value.Data.Count <= 0) { continue; } string lines = string.Format("PATH \"{0}:{1}\" ({2}):", pair.Key, pair.Value.name, '#' + ColorUtility.ToHtmlStringRGB(pair.Value.gizmoColor)); foreach (Recordable.Data data in pair.Value.Data) { string posString = string.Format("{0}, {1}, {2}", Utils.WriteFloat(data.pos.x), Utils.WriteFloat(data.pos.y), Utils.WriteFloat(data.pos.z)); lines += '\n' + string.Format("{0}: {1}, {2}", posString, Utils.WriteFloat(data.time), data.isBreak); } file.WriteLine(lines); file.WriteLine(); } } return(true); }
//Signals key activation and path recording private void Update() { if (pause || !recording) { return; } if (DontRecordInBuild) { return; } foreach (Signal.Config signal in signals) { if (!signal.ActivateOnKey || !signal.LookUpObject) { continue; } if (!string.IsNullOrEmpty(signal.Button) && Input.GetButtonDown(signal.Button)) { SendSignal(signals.IndexOf(signal)); } if (Input.GetKeyDown(signal.Key)) { SendSignal(signals.IndexOf(signal)); } } for (int i = 0; i < recordables.Count; i++) { if (!recordables[i].ObjectToRecord || !recordables[i].Record) { continue; } if (recordables[i].UpdateTimer()) { Recordable.Runtime runtimePath = runtimePaths[recordables[i].ObjectToRecord.name]; if (runtimePath.Data.Count <= 0) { runtimePath.Add(new Recordable.Data(Time.time, recordables[i].ObjectToRecord.position, false)); } else { Recordable.Data lastPoint = runtimePath.Data.Last(); if (Vector3.Distance(lastPoint.pos, recordables[i].ObjectToRecord.position) > 0.2f) { runtimePath.Add(new Recordable.Data(Time.time, recordables[i].ObjectToRecord.position, false)); } } } } }