Пример #1
0
        public virtual void TransferToUnityComponents(Entity entity, IBindingContext context)
        {
            var text2DRenderer = context.GetComponentData <Text2DRenderer>(entity);
            var text2DStyle    = context.GetComponentData <Text2DStyle>(entity);

            var text = context.GetUnityComponent <TText>(entity);

            if (context.HasComponent <TextString>(entity))
            {
                var textString = context.GetBufferRO <TextString>(entity).Reinterpret <char>().AsString();
                text.text = textString;
            }
            else
            {
                text.text = string.Empty;
            }

            text.fontStyle   = FontStyles.Normal;
            text.lineSpacing = 1;
            text.richText    = false;
            text.alignment   = Fonts.GetTextAlignmentFromPivot(text2DRenderer.pivot);
            var c = text2DStyle.color;

            text.color              = new Color(c.r, c.g, c.b, c.a);;
            text.fontSize           = text2DStyle.size * SizeFactor;
            text.isOrthographic     = true;
            text.enableWordWrapping = false;

            Transfer(entity, text, context);
        }