Ejemplo n.º 1
0
        protected override IEnumerator ProcessPayload(VisualPayload payload)
        {
            var label = VisualizerFactory.InstantiateLabelVisualizerPrefab();

            label.Initialize(this, payload);


            var meshRenderer = label.TextComponent.GetComponent <MeshRenderer>();

            var targetFont = FontFactory.GetFontPair(FontName.GetFirstValue(payload.Data));

            var newMaterial = FontFactory.GenerateNewSpatialMaterial(targetFont.FontTexture);

            label.TextComponent.font = targetFont.Font;

            label.TextComponent.fontSize  = Mathf.FloorToInt(FontSize.GetFirstValue(payload.Data) * targetFont.FontScale);
            label.transform.localPosition = new Vector3(0f, label.TextComponent.fontSize * targetFont.VerticalOffset, 0f);

            label.CharactersPerLine = CharactersPerLine.GetFirstValue(payload.Data);

            label.MaxLines = MaxLines.GetFirstValue(payload.Data);

            newMaterial.color = FontColor.GetFirstValue(payload.Data);

            meshRenderer.material = newMaterial;


            label.BackgroundPadding = BackgroundPadding.GetFirstValue(payload.Data);
            label.BackgroundDepth   = BackgroundDepth.GetFirstValue(payload.Data);

            label.LateralJustification = Justification.GetFirstValue(payload.Data);

            label.VerticalJustification = VerticalJustification.GetFirstValue(payload.Data);

            label.MinHeight = MinHeight.GetFirstValue(payload.Data);
            label.MaxHeight = MaxHeight.GetFirstValue(payload.Data);

            label.Orientation = Orientation.GetFirstValue(payload.Data);

            label.SetClickState(ClickState);

            label.RemoveBackground = !ShowBackground.GetFirstValue(payload.Data);

            label.Text = LabelText.GetFirstValue(payload.Data);

            var newPayload = new VisualPayload(payload.Data, new VisualDescription(label.Bound));

            var iterator = DefaultState.Transmit(newPayload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }