예제 #1
0
        /// <summary>
        /// setup
        /// </summary>
        public override void Awake()
        {
            _textComponent = GetComponent <UnityEngine.UI.Text>();
#if TEXTMESH_PRO
            if (_textComponent == null)
            {
                _textMeshProUGUI = GetComponent <TMPro.TextMeshProUGUI>();
                if (_textMeshProUGUI == null)
                {
                    _textMeshPro = GetComponent <TMPro.TextMeshPro>();
                    if (_textMeshPro == null)
                    {
                        MyDebug.LogErrorF("LocaliseText: No text or TextMesh Pro component found on {0}", gameObject.name);
                    }
                }
            }
#else
            if (_textComponent == null)
            {
                Debug.LogErrorFormat("LocaliseText: No text component found on {0}", gameObject.name);
            }
#endif


            // If no localization key has been specified, use the text value as the key
            if (string.IsNullOrEmpty(Key))
            {
                if (_textComponent != null)
                {
                    Key = _textComponent.text;
                }
#if TEXTMESH_PRO
                if (_textMeshProUGUI != null)
                {
                    Key = _textMeshProUGUI.text;
                }
                if (_textMeshPro != null)
                {
                    Key = _textMeshPro.text;
                }
#endif
            }
            base.Awake();
        }