Пример #1
0
        private void CosTest(Vector3 position)
        {
            LineGrapher graph = InstantiateGraph(position);

            graph.name       = "CosPlotTest";
            graph.MaxSamples = 250;
            graph.SetLabels("Cos vs. Time", "Time", "Cos(Time)");

            graph.YMax = 1;
            graph.YMin = -1;

            StartCoroutine(CosTest(graph));

            IEnumerator CosTest(LineGrapher cosGraph)
            {
                yield return(new WaitUntil(() => Time.time > 0));

                while (true)
                {
                    yield return(new WaitForFixedUpdate());

                    cosGraph.AddValue(Mathf.Cos(Time.time), Time.time);
                }
            }
        }
Пример #2
0
        private LineGrapher InstantiateGraph(Vector3 position)
        {
            GameObject go = (GameObject)Instantiate(graphPrefab, transform);

            go.transform.localPosition = position;
            LineGrapher graph = go.GetComponent <LineGrapher>();

            if (graph == null)
            {
                Debug.LogError("No LineGrapher found on " + go);
            }
            return(graph);
        }
Пример #3
0
        private void ConstantTest(Vector3 position)
        {
            LineGrapher graph = InstantiateGraph(position);

            graph.name       = "ConstPlotTest";
            graph.MaxSamples = 250;
            graph.SetLabels("Constant", "Time", "Y");

            graph.YMax = constant * 2;
            graph.YMin = 0;

            StartCoroutine(ConstantTest(graph));
            IEnumerator ConstantTest(LineGrapher constantGraph)
            {
                yield return(new WaitUntil(() => Time.time > 0));

                while (true)
                {
                    yield return(new WaitForFixedUpdate());

                    constantGraph.AddValue(constant, Time.time);
                }
            }
        }