44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
#define Graph_And_Chart_PRO
|
|
using UnityEngine;
|
|
using ChartAndGraph;
|
|
using System.Collections;
|
|
|
|
public class CurveAnimation : MonoBehaviour
|
|
{
|
|
void Start ()
|
|
{
|
|
GraphChartBase graph = GetComponent<GraphChartBase>();
|
|
if (graph != null)
|
|
{
|
|
|
|
graph.Scrollable = false;
|
|
graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
|
|
graph.DataSource.StartBatch();
|
|
graph.DataSource.ClearCategory("Player 1");
|
|
graph.DataSource.ClearAndMakeBezierCurve("Player 2");
|
|
|
|
for (int i = 0; i <5; i++)
|
|
{
|
|
graph.DataSource.AddPointToCategory("Player 1",i*5,Random.value*10f + 20f);
|
|
if (i == 0)
|
|
graph.DataSource.SetCurveInitialPoint("Player 2",i*5, Random.value * 10f + 10f);
|
|
else
|
|
graph.DataSource.AddLinearCurveToCategory("Player 2",
|
|
new DoubleVector2(i*5 , Random.value * 10f + 10f));
|
|
}
|
|
graph.DataSource.MakeCurveCategorySmooth("Player 2");
|
|
graph.DataSource.EndBatch();
|
|
graph.DataSource.AnimateCurve("Player 2", 1.0f);
|
|
}
|
|
// StartCoroutine(ClearAll());
|
|
}
|
|
|
|
IEnumerator ClearAll()
|
|
{
|
|
yield return new WaitForSeconds(5f);
|
|
GraphChartBase graph = GetComponent<GraphChartBase>();
|
|
|
|
graph.DataSource.Clear();
|
|
}
|
|
}
|