public float GetDesiredLabelLength(LabelBehaviour labelComponent) { var renderer = labelComponent.TextComponent.GetComponent <Renderer>(); var size = renderer.GetLocallyAlignedBounds(); const float padding = 0.30f; var totalSize = (size.x + (padding * 2.0f)); return(totalSize); }
public void SetLabelLength(LabelBehaviour labelComponent, float length) { var geomRenderer = labelComponent.Geometry.GetComponentInChildren <Renderer>(); var sizeGeom = geomRenderer.GetLocallyAlignedBounds(); var newScale = labelComponent.Geometry.localScale; newScale.x = length / sizeGeom.x; labelComponent.Geometry.localScale = newScale; }
public LabelBehaviour CreateLabel(string text, Vector3 pos, LabelOrientation labelOrientation, LabelBehaviour labelComponent = null) { if (labelComponent == null) { var labelGo = LabelSystemFactory.InstantiateLabel(); labelComponent = labelGo.GetComponent <LabelBehaviour>(); } labelComponent.Text = text; labelComponent.Orientation = labelOrientation; labelComponent.transform.SetParent(LabelRoot); labelComponent.transform.localPosition = pos; labelComponent.transform.localRotation = Quaternion.identity; LabelViews.Add(labelComponent); return(labelComponent); }