Пример #1
0
        /// <summary>
        /// Refresh.
        /// </summary>
        public void Refresh()
        {
            MyTextStyleManager.MyTextStyleInfo info = MyTextStyleManager.Instance.GetInfo(mStyle);
            if (info == null)
            {
                return;
            }

            if (mText == null)
            {
                mText = gameObject.GetComponent <Text>();
#if USE_MY_UI_TMPRO
                if (mText == null)
                {
                    mTextTMPro = gameObject.GetComponent <TextMeshProUGUI>();
                }
#endif
            }

            if (mText != null)
            {
                if (info.Font != null)
                {
                    mText.font = info.Font;
                }
                mText.fontSize = info.FontSizeMin;
                mText.color    = info.Color;
            }
#if USE_MY_UI_TMPRO
            else if (mTextTMPro != null)
            {
                if (info.TMPFontAsset != null)
                {
                    mTextTMPro.font = info.TMPFontAsset;
                }
                mTextTMPro.fontSize         = info.FontSizeMin;
                mTextTMPro.fontSizeMin      = info.FontSizeMin;
                mTextTMPro.fontSizeMax      = info.FontSizeMax;
                mTextTMPro.enableAutoSizing = info.FontSizeMin < info.FontSizeMax;
                mTextTMPro.color            = info.Color;
            }
#endif
        }
Пример #2
0
        /// <summary>
        /// OnInspectorGUI.
        /// </summary>
        public override void OnInspectorGUI()
        {
            EditorGUILayout.ObjectField("Script", MonoScript.FromMonoBehaviour(mScript), typeof(MyTextStyle), false);

            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            mStyle.enumValueIndex = (int)(MyTextStyleManager.EStyle)EditorGUILayout.EnumPopup("Style", (MyTextStyleManager.EStyle)mStyle.enumValueIndex);

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                mScript.Refresh();
            }

            MyTextStyleManager.MyTextStyleInfo info = MyTextStyleManager.Instance.GetInfo((MyTextStyleManager.EStyle)mStyle.enumValueIndex);
            EditorGUILayout.LabelField("Your Note", info != null ? info.Note : string.Empty);
        }