Beispiel #1
0
        public virtual void SetText(string text)
        {
            if (this.lastText == text)
            {
                return;
            }
            this.lastText      = text;
            this.lastValueData = default;

            #if UNITY_LOCALIZATION_SUPPORT
            if (this.avoidLocalizationUnsubscribe == false && this.lastLocalizationKey != null)
            {
                this.lastLocalizationKey.StringChanged -= this.OnLocalizationStringChanged;
                this.lastLocalizationKey = null;
            }
            #endif

            if (this.graphics is UnityEngine.UI.Text textGraphic)
            {
                textGraphic.text = text;
            }
#if TEXTMESHPRO_SUPPORT
            else if (this.graphics is TMPro.TMP_Text textGraphicTmp)
            {
                textGraphicTmp.text = text;
            }
#endif
        }
        public bool Parse(string data, System.Type fieldType, out object result)
        {
            var key   = JSONParser.FromJson <Key>(data);
            var keyId = key.keyId;

            UnityEngine.Localization.Tables.TableEntryReference entry = null;
            UnityEngine.Localization.Tables.TableReference      table = null;
            if (string.IsNullOrEmpty(keyId) == false)
            {
                entry = (UnityEngine.Localization.Tables.TableEntryReference) long.Parse(keyId);
            }
            else
            {
                entry = (UnityEngine.Localization.Tables.TableEntryReference)key.key;
            }

            if (key.table.StartsWith("GUID:") == true)
            {
                table = (UnityEngine.Localization.Tables.TableReference) new System.Guid(key.table.Substring(5));
            }
            else
            {
                table = (UnityEngine.Localization.Tables.TableReference)key.table;
            }

            result = new UnityEngine.Localization.LocalizedString()
            {
                TableReference      = table,
                TableEntryReference = entry,
            };

            return(true);
        }
Beispiel #3
0
        public virtual void SetText(UnityEngine.Localization.LocalizedString key, params object[] args)
        {
            if (this.lastLocalizationKey != key || args.Length > 0)
            {
                if (this.lastLocalizationKey != null)
                {
                    this.lastLocalizationKey.StringChanged -= this.OnLocalizationStringChanged;
                }

                this.lastLocalizationKey                = key;
                this.lastLocalizationKey.Arguments      = args;
                this.lastLocalizationKey.StringChanged += this.OnLocalizationStringChanged;
            }
        }