Пример #1
0
        private ITextComponent SetValue_INTERNAL(long value, TextValueFormat format, bool animate, bool fromTweener)
        {
            if (fromTweener == true && this.tempLastValue == value && this.tempLastFormat == format)
            {
                return(this);
            }
            this.tempLastValue  = value;
            this.tempLastFormat = format;

            var tag = this.GetCustomTag("TextComponent");

            if (fromTweener == false && TweenerGlobal.instance != null)
            {
                TweenerGlobal.instance.removeTweens(tag);
            }

            if (animate == true && TweenerGlobal.instance != null)
            {
                this.tempLastValue = value - 1L;

                var duration = this.valueAnimateDuration;
                if (Mathf.Abs(this.valueAnimateLastValue - value) < 2)
                {
                    duration = 0.2f;
                }
                TweenerGlobal.instance.addTweenCount(this, duration, this.valueAnimateLastValue, value, format, (v) => { this.valueAnimateLastValue = v; this.SetValue_INTERNAL(v, format, animate: false, fromTweener: true); }).tag(tag);
            }
            else
            {
                this.SetText_INTERNAL(TextComponent.FormatValue(value, format));
            }

            return(this);
        }
Пример #2
0
			public FPSCounter(MonoBehaviour mb, TextComponent textComponent) {

				this.mb = mb;
				this.textComponent = textComponent;
				this.alive = true;

				this.Start();

			}
Пример #3
0
        private void SetText_INTERNAL(string text)
        {
            if (text == null)
            {
                text = string.Empty;
            }

            if (this.text != null)
            {
                bool supportRichText = false;
                if (TextComponentUGUIAddon.IsValid(this.text) == true)
                {
                    supportRichText = TextComponentUGUIAddon.IsRichtextSupported(this.text);
                }
                if (TextComponentTMPAddon.IsValid(this.text) == true)
                {
                    supportRichText = TextComponentTMPAddon.IsRichtextSupported(this.text);
                }

                if (supportRichText == true)
                {
                    text = TextComponent.ParseRichText(text, this.GetFontSize(), this.richTextFlags);
                }

                text = TextComponent.FullTextFormat(text, this.fullTextFormat);

                if (this.lastText == text)
                {
                    return;
                }
                this.lastText = text;

                System.Action onComplete = () => {
                    if (TextComponentUGUIAddon.IsValid(this.text) == true)
                    {
                        TextComponentUGUIAddon.SetText(this.text, text);
                    }
                    if (TextComponentTMPAddon.IsValid(this.text) == true)
                    {
                        TextComponentTMPAddon.SetText(this.text, text);
                    }
                };

                if (this.textCrossFadeModule.IsValid() == true && TextComponentUGUIAddon.IsValid(this.text) == true)
                {
                    this.textCrossFadeModule.Prepare(this);
                    this.textCrossFadeModule.FadeTo(this, text, onComplete);
                }
                else
                {
                    onComplete.Invoke();
                }
            }
        }
Пример #4
0
        private void SetText_INTERNAL(string text)
        {
            if (this.text != null)
            {
                if (this.text.supportRichText == true)
                {
                    text = TextComponent.ParseRichText(text, this.GetFontSize(), this.richTextFlags);
                }

                text = TextComponent.FullTextFormat(text, this.fullTextFormat);

                this.text.text = text;
            }
        }
Пример #5
0
        private void SetText_INTERNAL(string text)
        {
            if (text == null)
            {
                text = string.Empty;
            }

            if (this.text != null)
            {
                bool supportRichText = false;
                if (TextComponentUGUIAddon.IsValid(this.text) == true)
                {
                    supportRichText = TextComponentUGUIAddon.IsRichtextSupported(this.text);
                }
                if (TextComponentTMPAddon.IsValid(this.text) == true)
                {
                    supportRichText = TextComponentTMPAddon.IsRichtextSupported(this.text);
                }

                if (supportRichText == true)
                {
                    text = TextComponent.ParseRichText(text, this.GetFontSize(), this.richTextFlags);
                }

                text = TextComponent.FullTextFormat(text, this.fullTextFormat);

                if (TextComponentUGUIAddon.IsValid(this.text) == true)
                {
                    TextComponentUGUIAddon.SetText(this.text, text);
                }
                if (TextComponentTMPAddon.IsValid(this.text) == true)
                {
                    TextComponentTMPAddon.SetText(this.text, text);
                }
            }
        }
Пример #6
0
        public static string FormatValue(double value, TextValueFormat format)
        {
            var output = string.Empty;

            switch (format)
            {
            case TextValueFormat.None: {
                output = value.ToString();

                break;
            }

            case TextValueFormat.WithSpace: {
                var minus = false;
                if (value < 0f)
                {
                    value = -value;
                    minus = true;
                }

                output = value.ToString("# ### ### ##0").Trim();

                if (minus == true)
                {
                    output = string.Format("-{0}", value);
                }

                break;
            }

            case TextValueFormat.WithComma: {
                var minus = false;
                if (value < 0f)
                {
                    value = -value;
                    minus = true;
                }

                output = value.ToString("#,### ### ##0").Trim(',').Trim();

                if (minus == true)
                {
                    output = string.Format("-{0}", value);
                }

                break;
            }

            case TextValueFormat.TimeDHMSFromSeconds: {
                var t = TimeSpan.FromSeconds(value);
                output = string.Format("{0}d {1:D2}:{2:D2}:{3:D2}", Mathf.FloorToInt((float)t.TotalDays), t.Hours, t.Minutes, t.Seconds);

                break;
            }

            case TextValueFormat.DateUniversalFromMilliseconds: {
                DateTime date = TextComponent.TimeStampToDateTime(value, milliseconds: true);
                output = date.ToString("U", System.Globalization.CultureInfo.CreateSpecificCulture(UnityEngine.UI.Windows.Plugins.Localization.LocalizationSystem.GetCultureNameByLanguage(UnityEngine.UI.Windows.Plugins.Localization.LocalizationSystem.GetCurrentLanguage())));

                break;
            }

            case TextValueFormat.DateDMHMS: {
                DateTime date = TextComponent.TimeStampToDateTime(value, milliseconds: false);
                output = date.ToString("dd MM HH:mm:ss");

                break;
            }

            case TextValueFormat.DateDMHMSFromMilliseconds: {
                DateTime date = TextComponent.TimeStampToDateTime(value, milliseconds: true);
                output = date.ToString("dd MM HH:mm:ss");

                break;
            }

            case TextValueFormat.TimeHMSFromSeconds: {
                var t = TimeSpan.FromSeconds(value);
                output = string.Format("{0:D2}:{1:D2}:{2:D2}", Mathf.FloorToInt((float)t.TotalHours), t.Minutes, t.Seconds);

                break;
            }

            case TextValueFormat.TimeMSFromSeconds: {
                var t = TimeSpan.FromSeconds(value);
                output = string.Format("{0:D2}:{1:D2}", Mathf.FloorToInt((float)t.TotalMinutes), t.Seconds);

                break;
            }

            case TextValueFormat.TimeHMSmsFromMilliseconds: {
                var t = TimeSpan.FromMilliseconds(value);
                output = string.Format("{0:D2}:{1:D2}:{2:D2}`{3:D2}", Mathf.FloorToInt((float)t.TotalHours), t.Minutes, t.Seconds, t.Milliseconds);

                break;
            }

            case TextValueFormat.TimeMSmsFromMilliseconds: {
                var t = TimeSpan.FromMilliseconds(value);
                output = string.Format("{0:D2}:{1:D2}`{2:D2}", Mathf.FloorToInt((float)t.TotalMinutes), t.Seconds, t.Milliseconds);

                break;
            }

            case TextValueFormat.TimeMSFromMilliseconds: {
                var t = TimeSpan.FromMilliseconds(value);
                output = string.Format("{0:D2}:{1:D2}", Mathf.FloorToInt((float)t.TotalMinutes), t.Seconds);

                break;
            }

            case TextValueFormat.TimeHMSFromMilliseconds: {
                var t = TimeSpan.FromMilliseconds(value);
                output = string.Format("{0:D2}:{1:D2}:{2:D2}", Mathf.FloorToInt((float)t.TotalHours), t.Minutes, t.Seconds);

                break;
            }
            }

            return(output);
        }
Пример #7
0
 public static string FormatValue(long value, TextValueFormat format)
 {
     return(TextComponent.FormatValue((double)value, format));
 }
Пример #8
0
 public ITextComponent SetHyphenSymbol()
 {
     return(this.SetText(TextComponent.GetHyphenSymbol()));
 }
Пример #9
0
 public void SetValue(int value, ValueFormat format = ValueFormat.None)
 {
     this.SetText(TextComponent.FormatValue(value, format));
 }
		public void SetValue(int value, TextComponent.ValueFormat format = TextComponent.ValueFormat.None) {

			this.SetText(TextComponent.FormatValue(value, format));
			
		}