private void UpdateView() { if (labelText == null || lineRenderer == null) { return; } labelText.SetLabelText(Label); labelText.SetLabelColor(IndicatorColor); labelText.SetLabelTextSize(FontSize); lineRenderer.Points = LinePoints.ToArray(); lineRenderer.color = IndicatorColor; if (ReversedLabel) { labelText.SetLabelTextAlignment(TextAnchor.MiddleRight); labelText.GetComponent <RectTransform> ().pivot = PivotValue.MIDDLE_RIGHT; } else { labelText.SetLabelTextAlignment(TextAnchor.MiddleLeft); labelText.GetComponent <RectTransform> ().pivot = PivotValue.MIDDLE_LEFT; } }
private void InstantiateViews() { labelText = viewCreator.InstantiateWithPrefab <ChartLabel> (labelPrafab, transform); labelText.GetComponent <RectTransform> ().anchorMin = new Vector2(0.5f, 0.5f); labelText.GetComponent <RectTransform> ().anchorMax = new Vector2(0.5f, 0.5f); labelText.GetComponent <RectTransform> ().sizeDelta = new Vector2(300f, 40f); lineRenderer = viewCreator.InstantiateLineRenderer("line", transform, PivotValue.CENTER); lineRenderer.GetComponent <RectTransform> ().anchorMin = new Vector2(0.5f, 0.5f); lineRenderer.GetComponent <RectTransform> ().anchorMax = new Vector2(0.5f, 0.5f); lineRenderer.lineThickness = 2.0f; }
private void UpdateLabel(ChartLabel label, AxisLabelConfig config, AxisLabelRendererExtry entry, Vector2 rendererSize) { label.SetLabelColor(config.LabelColor); label.SetLabelTextSize(config.LabelSize); label.SetLabelTextAlignment(GetLabelAlignment(entry)); label.SetLabelText(entry.Text); label.GetComponent <RectTransform> ().pivot = GetLabelPivot(entry); label.transform.localPosition = CreateLabelPositionForEntry(entry, rendererSize, config.LabelMargin); }
private void UpdatePositionsAndSizes() { if (iconImage == null || nameLabel == null) { return; } RectTransform viewTransform = GetComponent <RectTransform>(); RectTransform iconTransform = iconImage.GetComponent <RectTransform>(); RectTransform titleTransform = nameLabel.GetComponent <RectTransform>(); iconTransform.sizeDelta = new Vector2(IconSize, IconSize); titleTransform.sizeDelta = new Vector2(viewTransform.sizeDelta.x - IconSize - IconSpacing, viewTransform.sizeDelta.y); titleTransform.anchoredPosition = new Vector3(IconSize + IconSpacing, 0f, 0f); isDirty = false; }