/// <summary> /// Starts a graph with the given values. /// </summary> /// <param name="values">A list of floats which you want to display. Can be empty.</param> /// <param name="displayedSeconds">How many seconds you want to display (time frame).</param> public void Initialize(List <float> values, float displayedSeconds) { // return when the function is called with bad values if (values == null) { values = new List <float>(); } if (displayedSeconds < 2 * Time.deltaTime) { Debug.Log("Cannot start a graph with less than 2 points!"); return; } m_GraphRenderer = gameObject.AddComponent <GraphRenderer>(); // fill the list if necessary if (values.Count < m_DisplayedPointsCount) { m_Values = values; m_Values.AddRange(Enumerable.Repeat(m_DefaultValue, m_DisplayedPointsCount).ToList()); } // init values m_Values = values; // init graph renderer m_GraphRenderer.Initialize(m_Values, m_DisplayedPointsCount); DisplayForNumberOfSeconds(displayedSeconds); }
//public void Initialize(List<float> values) //{ // transform.GetComponentsInChildren() //} public void CreateGraphRenderers(int motorCountLeft, int currentPage, ModeManager.Panelmode panelMode, RoboyPart roboyPart) { int motorsToCreate = Mathf.Min(4, motorCountLeft); for (int i = 0; i < motorsToCreate; i++) { GraphRenderer graphRenderer = Instantiate(GraphRendererPrefab, Vector3.zero, Quaternion.identity); graphRenderer.transform.SetParent(transform, false); string motorIndex = "Motor" + (i + currentPage * 4); graphRenderer.TextForValueName.text = motorIndex; //Debug.Log(motorIndex); graphRenderer.Initialize(roboyPart.Categories[panelMode].Motors[motorIndex].Values, 30, 0f); graphRenderer.Play(); GraphRenderers.Add(graphRenderer); } }