public void ShowPlot(Global.GraphType gType, float x, float y) { GraphAttributes gt = gAttr[gType]; float xPos = (x / gt.xMax) * graphWidth; // Normalized x position float yPos = (y / gt.yMax) * graphHeight; // Normalized y position GameObject goCircle = CreateCircle(new Vector2(xPos, yPos), gt.pointColor); gt.points.Add(goCircle); if (gt.lastCircleGameObject != null) { GameObject goConn = CreateDotConnection(gt.lastCircleGameObject.GetComponent <RectTransform>().anchoredPosition, goCircle.GetComponent <RectTransform>().anchoredPosition, gt.segmentColor, gt.segmentWidth); gt.segments.Add(goConn); } gt.lastCircleGameObject = goCircle; gAttr[gType] = gt; }
public void ClearPlot(Global.GraphType gType) { if (gAttr.ContainsKey(gType) == false) { return; } GraphAttributes gt = gAttr[gType]; foreach (var go in gt.points) { Destroy(go); } foreach (var go in gt.segments) { Destroy(go); } }
public void GraphInit(Global.GraphType gType, Color pointColor, Color segmentColor, float xMax, float yMax, float segmentWidth = 1f) { GraphAttributes gt = new GraphAttributes(); gt.lastCircleGameObject = null; gt.pointColor = pointColor; gt.segmentColor = segmentColor; gt.xMax = xMax; gt.yMax = yMax; gt.points = new List <GameObject>(); gt.segments = new List <GameObject>(); gt.segmentWidth = segmentWidth; if (gAttr.ContainsKey(gType) == true) { gAttr[gType] = gt; } else { gAttr.Add(gType, gt); } }