//Create telemetry data text for the right panel //Index 0 is at the top of the panel void CreateTelemetryText(TelemetryData t, int index, TelemetryType ttype) { if (t == null) { return; } float offset; if (ttype == TelemetryType.NUMERICAL) { offset = -1.5f; } else if (ttype == TelemetryType.SWITCH) { offset = 4.0f; } else { offset = 7.5f; } GameObject textNameClone = Instantiate(telemetryTextName, textPanel.GetComponent <Transform>(), false); GameObject textNumberClone = Instantiate(telemetryTextNumber, textPanel.GetComponent <Transform>(), false); textNameClone.GetComponent <RectTransform>().localPosition = new Vector3((float)0.75, (float)(3.5 - 0.4 * index) - offset, 0); textNumberClone.GetComponent <RectTransform>().localPosition = new Vector3((float)-0.75, (float)(3.5 - 0.4 * index) - offset, 0); //Set color based on severity switch (t.severity) { case Severity.NOMINAL: textNameClone.GetComponentInChildren <Text>().color = Constants.WHITE; textNumberClone.GetComponentInChildren <Text>().color = Constants.WHITE; break; case Severity.WARNING: textNameClone.GetComponentInChildren <Text>().color = Constants.YELLOW; textNumberClone.GetComponentInChildren <Text>().color = Constants.YELLOW; break; case Severity.CRITICAL: textNameClone.GetComponentInChildren <Text>().color = Constants.RED; textNumberClone.GetComponentInChildren <Text>().color = Constants.RED; break; case Severity.UNKNOWN: textNameClone.GetComponentInChildren <Text>().color = Constants.RED; textNumberClone.GetComponentInChildren <Text>().color = Constants.RED; break; } //Set text textNameClone.GetComponentInChildren <Text>().text = t.GetNameText(); textNumberClone.GetComponentInChildren <Text>().text = t.GetValueText(); }