/// <summary> /// Process new packets that are related with BioFeedback Variables /// </summary> /// <param name="packet"></param> public void ProcessBioFeedbackPacket(PhysioPacket packet) { bool existingVariable = false; // Check whether the variable was already configured for (int i = 0; i < bfVariables.Count; i++) { // If the variable name already exists... if (bfVariables[i].name.CompareTo(packet.variableName) == 0) { existingVariable = true; bfVariables[i].values.Add(packet.value); break; } } // New variable to save if (!existingVariable) { BiofeedbackVariable newBfVariable = new BiofeedbackVariable(); newBfVariable.name = packet.variableName; newBfVariable.values = new List <float>() { packet.value }; bfVariables.Add(newBfVariable); } }
/// <summary> /// Set instance for settings object and initialize callbacks of UI /// </summary> private void Awake() { // Check singleton, each time the menu scene is loaded, the instance is replaced with the newest script if (instance == null) { instance = this; } else { // Update Singleton when loading a new scene Destroy(instance.gameObject); instance = this; } // Variables bfVariables = new BiofeedbackVariable[numberOfBfvariables]; BiofeedbackVariable bf1 = new BiofeedbackVariable(); bf1.slotOccupied = false; bf1.label = bfText1; bf1.slider = bfSlider1; BiofeedbackVariable bf2 = new BiofeedbackVariable(); bf2.slotOccupied = false; bf2.label = bfText2; bf2.slider = bfSlider2; BiofeedbackVariable bf3 = new BiofeedbackVariable(); bf3.slotOccupied = false; bf3.label = bfText3; bf3.slider = bfSlider3; bfVariables[0] = bf1; bfVariables[1] = bf2; bfVariables[2] = bf3; }