// Update plotters and show if visualizeData[idx] is true; // Update the materials before to ensure there is a renderer attached to the child object. public override void UpdateMesh() { float[] yStartPos = new float[numberOfSamples]; for (int i = 0; i < numberOfSamples; i++) { yStartPos[i] = 0; } Vector3[] lines = new Vector3[numberOfSamples * 2]; Transform trans = PlotterGroup.transform; float xScale = chartSize.x / (numberOfSamples); float yScale = chartSize.y; for (int childIdx = 0; childIdx < trans.childCount; childIdx++) { string name = MeshUtils.NameGenerator(Identifier, childIdx); GameObject obj = trans.Find(name).gameObject; DataSeries pltr = obj.GetComponent <DataSeries>(); // Sometimes the materials might have been changed during scheduledUpdate if (childIdx < Materials.Length) { pltr.UpdateMaterial(Materials[childIdx]); } // Sometimes the visualizeData might have been changed during scheduledUpdate if (childIdx < visualizeData.Length) { pltr.GetComponent <Renderer>().enabled = visualizeData[childIdx]; if (!visualizeData[childIdx]) { continue; } } float[] currentSeries = pltr.GetRearrangedData(); int xIdx = numberOfSamples; int lineIdx = 0; float xPos, yPos; for (int idx = 0; idx < currentSeries.Length; idx++) { xPos = (xIdx - .5f) * xScale; yPos = yStartPos[idx]; lines[lineIdx++] = new Vector3(xPos, yPos); yPos += currentSeries[idx] * yScale; lines[lineIdx++] = new Vector3(xPos, yPos); yStartPos[idx] = yPos; xIdx--; } pltr.UpdateMesh(MeshUtils.GenerateLineMesh(lines, xScale)); } }