// Update is called once per frame void Update() { if (Chart == null) { return; } Vector3 res; if (Chart.PointToWorldSpace(out res, point.x, point.y)) { TextObject.transform.position = res + new Vector3(SeperationOffset, ElevationOffset, 0f); } }
// Update is called once per frame void Update() { if (Chart == null) { return; } Vector3 res1, res2; if (Chart.PointToWorldSpace(out res1, point1.x, point1.y)) { if (Chart.PointToWorldSpace(out res2, point2.x, point2.y)) { Vector2 finalPos = (res2 + res1) * 0.5f; Vector2 seperationVector = (res2 - res1).normalized; Vector2 elevationVector = ChartCommon.Perpendicular(seperationVector); TextObject.transform.position = finalPos + SeperationOffset * seperationVector + ElevationOffset * elevationVector; if (Rotate) { TextObject.transform.localRotation = Quaternion.Euler(0f, 0f, Mathf.Rad2Deg * Mathf.Atan2(seperationVector.y, seperationVector.x)); } } } }
void Redraw() { if (Chart == null) { return; } DoubleVector3 last; if (Chart.DataSource.GetLastPoint("Player 1", out last)) { if (TrackLast == false) { last.y = yPosition; } Vector3 pos; DoubleRect rect = new DoubleRect(last.x - Chart.DataSource.HorizontalViewSize, last.y - lineThickness * 0.5f, Chart.DataSource.HorizontalViewSize, lineThickness); DoubleRect trimRect; if (Area != null) { Vector3 res; if (Chart.PointToWorldSpace(out res, rect.min.x, rect.min.y)) { res.y += lineThickness; double x, y; if (Chart.PointToClient(res, out x, out y)) { double thick = Math.Abs(rect.min.y - y); rect = new DoubleRect(last.x - Chart.DataSource.HorizontalViewSize, last.y - thick * 0.5f, Chart.DataSource.HorizontalViewSize, thick); } } if (Chart.TrimRect(rect, out trimRect)) // if the rect is in display { if (Area.gameObject.activeSelf == false) // we draw it { Area.gameObject.SetActive(true); } Chart.RectToCanvas(Area, trimRect); // Area.sizeDelta = new Vector2(Area.sizeDelta.x, lineThickness); } else { if (Area.gameObject.activeSelf == true) // otherwise it is set as incative { Area.gameObject.SetActive(false); } } } } }
void Redraw() { if (Chart == null) { return; } if (Chart.IsRectVisible(currentRect) == false) { double endX = (float)(Chart.HorizontalScrolling + Chart.DataSource.HorizontalViewSize); double x = endX - 1f; double y = (float)Chart.VerticalScrolling; double endY = (float)Chart.DataSource.GetMaxValue(1, false); currentRect = new DoubleRect(x, y, endX - x, endY - y); } DoubleRect trimRect; if (Chart.TrimRect(currentRect, out trimRect)) { Chart.RectToCanvas(Area, trimRect); } DoubleVector3 last; if (Chart.DataSource.GetLastPoint("Player 1", out last)) { Vector3 pos; if (Chart.PointToWorldSpace(out pos, last.x, last.y, "Player 1")) { if (LastPoint != null) { LastPoint.transform.position = pos; } } } }