Beispiel #1
0
        public override void ApplyStyles()
        {
            base.ApplyStyles();
            Text.font               = Style.font;
            Text.fontSize           = Style.fontSizeActual;
            Text.fontStyle          = Style.fontStyle;
            Text.fontWeight         = Style.fontWeight;
            Text.color              = Style.fontColor;
            Text.enableWordWrapping = Style.textWrap;
            Text.alignment          = Style.textAlign;

            var isLinked = Style.textOverflow == TextOverflowModes.Linked;

            if (isLinked && !LinkedTextWatcher)
            {
                LinkedTextWatcher             = GameObject.AddComponent <LinkedTextWatcher>();
                LinkedTextWatcher.WatchedText = this;
            }
            else if (!isLinked && LinkedTextWatcher)
            {
                GameObject.Destroy(LinkedTextWatcher);
                if (LinkedTextWatcher?.LinkedText != null)
                {
                    LinkedTextWatcher.LinkedText.Destroy();
                }
                LinkedTextWatcher = null;
            }

            // Page is appropriate here because it calculates firstOverflowCharacterIndex and masks the text at the same time
            Text.overflowMode = isLinked ? TextOverflowModes.Page : Style.textOverflow;
        }
Beispiel #2
0
        public override void ApplyStyles()
        {
            base.ApplyStyles();
            ComputedStyle.fontFamily.Get(Context, font =>
            {
                Text.font = font;
            });
            Text.fontSize           = ComputedStyle.fontSizeActual;
            Text.fontStyle          = ComputedStyle.fontStyle;
            Text.fontWeight         = ComputedStyle.fontWeight;
            Text.color              = ComputedStyle.color;
            Text.enableWordWrapping = ComputedStyle.textWrap;
            Text.alignment          = ComputedStyle.textAlign;
            Text.overflowMode       = ComputedStyle.textOverflow;
            if (ComputedStyle.content != null)
            {
                Text.text      = ComputedStyle.content;
                TextSetByStyle = true;
            }
            else if (TextSetByStyle)
            {
                Text.text      = TextInside;
                TextSetByStyle = false;
            }

            var isLinked = ComputedStyle.textOverflow == TextOverflowModes.Linked;

            if (isLinked && !LinkedTextWatcher)
            {
                LinkedTextWatcher             = AddComponent <LinkedTextWatcher>();
                LinkedTextWatcher.WatchedText = this;
            }
            else if (!isLinked && LinkedTextWatcher)
            {
                GameObject.Destroy(LinkedTextWatcher);
                if (LinkedTextWatcher?.LinkedText != null)
                {
                    LinkedTextWatcher.LinkedText.Destroy();
                }
                LinkedTextWatcher = null;
            }
        }