コード例 #1
0
        /// <summary>

        /// Function to pre-load the TMP Resources

        /// </summary>

        public static void LoadTextMeshProResources()

        {
            TMP_Settings.LoadDefaultSettings();

            TMP_StyleSheet.LoadDefaultStyleSheet();
        }
コード例 #2
0
        public static void CreateTextMeshProObjectPerform()
        {
            string filePath;

            if (Selection.assetGUIDs.Length == 0)
            {
                // No asset selected.
                filePath = "Assets";
            }
            else
            {
                // Get the path of the selected folder or asset.
                filePath = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);

                // Get the file extension of the selected asset as it might need to be removed.
                string fileExtension = Path.GetExtension(filePath);
                if (fileExtension != "")
                {
                    filePath = Path.GetDirectoryName(filePath);
                }
            }


            string filePathWithName = AssetDatabase.GenerateUniqueAssetPath(filePath + "/TMP StyleSheet.asset");

            //// Create new Style Sheet Asset.
            TMP_StyleSheet styleSheet = ScriptableObject.CreateInstance <TMP_StyleSheet>();

            AssetDatabase.CreateAsset(styleSheet, filePathWithName);

            EditorUtility.SetDirty(styleSheet);

            AssetDatabase.SaveAssets();
        }
        public static void CreateTextMeshProObjectPerform()
        {
            // Get the path to the selected texture.
            string filePath         = AssetDatabase.GetAssetPath(Selection.activeObject);
            string filePathWithName = AssetDatabase.GenerateUniqueAssetPath(filePath + "/TMP_DefaultStyleSheet.asset");

            // Create new Sprite Asset using this texture
            TMP_StyleSheet styleManager = ScriptableObject.CreateInstance <TMP_StyleSheet>();

            //colorGradient.SetDefaultColors(Color.white);

            AssetDatabase.CreateAsset(styleManager, filePathWithName);

            EditorUtility.SetDirty(styleManager);

            AssetDatabase.SaveAssets();
        }
コード例 #4
0
        public static void CreateTextMeshProObjectPerform()
        {
            string text;

            if (Selection.assetGUIDs.Length == 0)
            {
                text = "Assets";
            }
            else
            {
                text = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
                string extension = Path.GetExtension(text);
                if (extension != "")
                {
                    text = Path.GetDirectoryName(text);
                }
            }
            string         path           = AssetDatabase.GenerateUniqueAssetPath(text + "/TMP StyleSheet.asset");
            TMP_StyleSheet tMP_StyleSheet = ScriptableObject.CreateInstance <TMP_StyleSheet>();

            AssetDatabase.CreateAsset(tMP_StyleSheet, path);
            EditorUtility.SetDirty(tMP_StyleSheet);
            AssetDatabase.SaveAssets();
        }
コード例 #5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty nameProperty              = property.FindPropertyRelative("m_Name");
            SerializedProperty hashCodeProperty          = property.FindPropertyRelative("m_HashCode");
            SerializedProperty openingDefinitionProperty = property.FindPropertyRelative("m_OpeningDefinition");
            SerializedProperty closingDefinitionProperty = property.FindPropertyRelative("m_ClosingDefinition");
            SerializedProperty openingDefinitionArray    = property.FindPropertyRelative("m_OpeningTagArray");
            SerializedProperty closingDefinitionArray    = property.FindPropertyRelative("m_ClosingTagArray");


            EditorGUIUtility.labelWidth = 90;
            position.height             = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            float labelHeight = position.height + 2f;

            EditorGUI.BeginChangeCheck();
            Rect rect0 = new Rect(position.x, position.y, (position.width) / 2 + 5, position.height);

            EditorGUI.PropertyField(rect0, nameProperty);
            if (EditorGUI.EndChangeCheck())
            {
                // Recompute HashCode if name has changed.
                hashCodeProperty.intValue = TMP_TextUtilities.GetSimpleHashCode(nameProperty.stringValue);

                property.serializedObject.ApplyModifiedProperties();
                // Dictionary needs to be updated since HashCode has changed.
                TMP_StyleSheet.RefreshStyles();
            }

            // HashCode
            Rect rect1 = new Rect(rect0.x + rect0.width + 5, position.y, 65, position.height);

            GUI.Label(rect1, "HashCode");
            GUI.enabled = false;
            rect1.x    += 65;
            rect1.width = position.width / 2 - 75;
            EditorGUI.PropertyField(rect1, hashCodeProperty, GUIContent.none);

            GUI.enabled = true;

            // Text Tags
            EditorGUI.BeginChangeCheck();

            // Opening Tags
            position.y += labelHeight;
            GUI.Label(position, "Opening Tags");
            Rect textRect1 = new Rect(108, position.y, position.width - 86, 35);

            openingDefinitionProperty.stringValue = EditorGUI.TextArea(textRect1, openingDefinitionProperty.stringValue);
            if (EditorGUI.EndChangeCheck())
            {
                // If any properties have changed, we need to update the Opening and Closing Arrays.
                int size = openingDefinitionProperty.stringValue.Length;

                // Adjust array size to match new string length.
                if (openingDefinitionArray.arraySize != size)
                {
                    openingDefinitionArray.arraySize = size;
                }

                for (int i = 0; i < size; i++)
                {
                    SerializedProperty element = openingDefinitionArray.GetArrayElementAtIndex(i);
                    element.intValue = openingDefinitionProperty.stringValue[i];
                }
            }

            EditorGUI.BeginChangeCheck();

            // Closing Tags
            position.y += 38;
            GUI.Label(position, "Closing Tags");
            Rect textRect2 = new Rect(108, position.y, position.width - 86, 35);

            closingDefinitionProperty.stringValue = EditorGUI.TextArea(textRect2, closingDefinitionProperty.stringValue);

            if (EditorGUI.EndChangeCheck())
            {
                // If any properties have changed, we need to update the Opening and Closing Arrays.
                int size = closingDefinitionProperty.stringValue.Length;

                // Adjust array size to match new string length.
                if (closingDefinitionArray.arraySize != size)
                {
                    closingDefinitionArray.arraySize = size;
                }

                for (int i = 0; i < size; i++)
                {
                    SerializedProperty element = closingDefinitionArray.GetArrayElementAtIndex(i);
                    element.intValue = closingDefinitionProperty.stringValue[i];
                }
            }
        }
コード例 #6
0
        public override void OnInspectorGUI()
        {
            Event currentEvent = Event.current;

            serializedObject.Update();

            int arraySize    = m_StyleListProp.arraySize;
            int itemsPerPage = (Screen.height - 178) / 111;

            if (arraySize > 0)
            {
                // Display each Style entry using the StyleDrawer PropertyDrawer.
                for (int i = itemsPerPage * m_Page; i < arraySize && i < itemsPerPage * (m_Page + 1); i++)
                {
                    // Define the start of the selection region of the element.
                    Rect elementStartRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    SerializedProperty spriteInfo = m_StyleListProp.GetArrayElementAtIndex(i);
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(spriteInfo);
                    EditorGUILayout.EndVertical();
                    if (EditorGUI.EndChangeCheck())
                    {
                        //
                    }

                    // Define the end of the selection region of the element.
                    Rect elementEndRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));

                    // Check for Item selection
                    Rect selectionArea = new Rect(elementStartRegion.x, elementStartRegion.y, elementEndRegion.width, elementEndRegion.y - elementStartRegion.y);
                    if (DoSelectionCheck(selectionArea))
                    {
                        if (m_SelectedElement == i)
                        {
                            m_SelectedElement = -1;
                        }
                        else
                        {
                            m_SelectedElement          = i;
                            GUIUtility.keyboardControl = 0;
                        }
                    }

                    // Handle Selection Highlighting
                    if (m_SelectedElement == i)
                    {
                        TMP_EditorUtility.DrawBox(selectionArea, 2f, new Color32(40, 192, 255, 255));
                    }
                }
            }

            int shiftMultiplier = currentEvent.shift ? 10 : 1; // Page + Shift goes 10 page forward

            GUILayout.Space(-3f);

            Rect pagePos = EditorGUILayout.GetControlRect(false, 20);

            pagePos.width /= 6;

            // Return if we can't display any items.
            if (itemsPerPage == 0)
            {
                return;
            }


            // Add new style.
            pagePos.x += pagePos.width * 4;
            if (GUI.Button(pagePos, "+"))
            {
                m_StyleListProp.arraySize += 1;
                serializedObject.ApplyModifiedProperties();
                TMP_StyleSheet.RefreshStyles();
            }


            // Delete selected style.
            pagePos.x += pagePos.width;
            if (m_SelectedElement == -1)
            {
                GUI.enabled = false;
            }
            if (GUI.Button(pagePos, "-"))
            {
                if (m_SelectedElement != -1)
                {
                    m_StyleListProp.DeleteArrayElementAtIndex(m_SelectedElement);
                }

                m_SelectedElement = -1;
                serializedObject.ApplyModifiedProperties();
                TMP_StyleSheet.RefreshStyles();
            }

            GUILayout.Space(5f);

            pagePos        = EditorGUILayout.GetControlRect(false, 20);
            pagePos.width /= 3;


            // Previous Page
            if (m_Page > 0)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }

            if (GUI.Button(pagePos, "Previous"))
            {
                m_Page -= 1 * shiftMultiplier;
            }

            // PAGE COUNTER
            GUI.enabled = true;
            pagePos.x  += pagePos.width;
            int totalPages = (int)(arraySize / (float)itemsPerPage + 0.999f);

            GUI.Label(pagePos, "Page " + (m_Page + 1) + " / " + totalPages, TMP_UIStyleManager.centeredLabel);

            // Next Page
            pagePos.x += pagePos.width;
            if (itemsPerPage * (m_Page + 1) < arraySize)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }

            if (GUI.Button(pagePos, "Next"))
            {
                m_Page += 1 * shiftMultiplier;
            }

            // Clamp page range
            m_Page = Mathf.Clamp(m_Page, 0, arraySize / itemsPerPage);


            if (serializedObject.ApplyModifiedProperties())
            {
                TMPro_EventManager.ON_TEXT_STYLE_PROPERTY_CHANGED(true);
            }

            // Clear selection if mouse event was not consumed.
            GUI.enabled = true;
            if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0)
            {
                m_SelectedElement = -1;
            }
        }
コード例 #7
0
ファイル: StyleDrawer.cs プロジェクト: nickc01/WeaverCore
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty serializedProperty  = property.FindPropertyRelative("m_Name");
            SerializedProperty serializedProperty2 = property.FindPropertyRelative("m_HashCode");
            SerializedProperty serializedProperty3 = property.FindPropertyRelative("m_OpeningDefinition");
            SerializedProperty serializedProperty4 = property.FindPropertyRelative("m_ClosingDefinition");
            SerializedProperty serializedProperty5 = property.FindPropertyRelative("m_OpeningTagArray");
            SerializedProperty serializedProperty6 = property.FindPropertyRelative("m_ClosingTagArray");

            EditorGUIUtility.labelWidth = 90f;
            position.height             = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            float num = position.height + 2f;

            EditorGUI.BeginChangeCheck();
            Rect position2 = new Rect(position.x, position.y, position.width / 2f + 5f, position.height);

            EditorGUI.PropertyField(position2, serializedProperty);
            if (EditorGUI.EndChangeCheck())
            {
                serializedProperty2.intValue = TMP_TextUtilities.GetSimpleHashCode(serializedProperty.stringValue);
                property.serializedObject.ApplyModifiedProperties();
                TMP_StyleSheet.RefreshStyles();
            }
            Rect position3 = new Rect(position2.x + position2.width + 5f, position.y, 65f, position.height);

            GUI.Label(position3, "HashCode");
            GUI.enabled     = false;
            position3.x    += 65f;
            position3.width = position.width / 2f - 75f;
            EditorGUI.PropertyField(position3, serializedProperty2, GUIContent.none);
            GUI.enabled = true;
            EditorGUI.BeginChangeCheck();
            position.y += num;
            GUI.Label(position, "Opening Tags");
            Rect position4 = new Rect(108f, position.y, position.width - 86f, 35f);

            serializedProperty3.stringValue = EditorGUI.TextArea(position4, serializedProperty3.stringValue);
            if (EditorGUI.EndChangeCheck())
            {
                int length = serializedProperty3.stringValue.Length;
                if (serializedProperty5.arraySize != length)
                {
                    serializedProperty5.arraySize = length;
                }
                for (int i = 0; i < length; i++)
                {
                    SerializedProperty arrayElementAtIndex = serializedProperty5.GetArrayElementAtIndex(i);
                    arrayElementAtIndex.intValue = serializedProperty3.stringValue[i];
                }
            }
            EditorGUI.BeginChangeCheck();
            position.y += 38f;
            GUI.Label(position, "Closing Tags");
            Rect position5 = new Rect(108f, position.y, position.width - 86f, 35f);

            serializedProperty4.stringValue = EditorGUI.TextArea(position5, serializedProperty4.stringValue);
            if (EditorGUI.EndChangeCheck())
            {
                int length2 = serializedProperty4.stringValue.Length;
                if (serializedProperty6.arraySize != length2)
                {
                    serializedProperty6.arraySize = length2;
                }
                for (int j = 0; j < length2; j++)
                {
                    SerializedProperty arrayElementAtIndex2 = serializedProperty6.GetArrayElementAtIndex(j);
                    arrayElementAtIndex2.intValue = serializedProperty4.stringValue[j];
                }
            }
        }
 void OnEnable()
 {
     m_StyleSheet    = target as TMP_StyleSheet;
     m_StyleListProp = serializedObject.FindProperty("m_StyleList");
 }
コード例 #9
0
ファイル: TMP_SettingsEditor.cs プロジェクト: veboys/UIForia
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            float labelWidth = EditorGUIUtility.labelWidth;
            float fieldWidth = EditorGUIUtility.fieldWidth;

            // TextMeshPro Font Info Panel
            EditorGUI.indentLevel = 0;

            // FONT ASSET
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.defaultFontAssetLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropFontAsset, Styles.defaultFontAssetLabel);
            EditorGUILayout.PropertyField(m_PropDefaultFontAssetPath, Styles.defaultFontAssetPathLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // FALLBACK FONT ASSETs
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.fallbackFontAssetsLabel, EditorStyles.boldLabel);
            m_List.DoLayoutList();

            GUILayout.Label(Styles.fallbackMaterialSettingsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropMatchMaterialPreset, Styles.matchMaterialPresetLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // MISSING GLYPHS
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.missingGlyphsTitleLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropMissingGlyphCharacter, Styles.missingGlyphLabel);
            EditorGUILayout.PropertyField(m_PropWarningsDisabled, Styles.disableWarningsLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // TEXT OBJECT DEFAULT PROPERTIES
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.containerDefaultSettingsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;

            EditorGUILayout.PropertyField(m_PropDefaultTextMeshProTextContainerSize, Styles.textMeshProLabel);
            EditorGUILayout.PropertyField(m_PropDefaultTextMeshProUITextContainerSize, Styles.textMeshProUiLabel);
            EditorGUILayout.PropertyField(m_PropAutoSizeTextContainer, Styles.autoSizeContainerLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();

            GUILayout.Label(Styles.textComponentDefaultSettingsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropDefaultFontSize, Styles.defaultFontSize);

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel(Styles.autoSizeRatioLabel);
                EditorGUIUtility.labelWidth = 32;
                EditorGUIUtility.fieldWidth = 10;

                EditorGUI.indentLevel = 0;
                EditorGUILayout.PropertyField(m_PropDefaultAutoSizeMinRatio, Styles.minLabel);
                EditorGUILayout.PropertyField(m_PropDefaultAutoSizeMaxRatio, Styles.maxLabel);
                EditorGUI.indentLevel = 1;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUIUtility.labelWidth = labelWidth;
            EditorGUIUtility.fieldWidth = fieldWidth;

            EditorGUILayout.PropertyField(m_PropWordWrapping, Styles.wordWrappingLabel);
            EditorGUILayout.PropertyField(m_PropKerning, Styles.kerningLabel);

            EditorGUILayout.PropertyField(m_PropExtraPadding, Styles.extraPaddingLabel);
            EditorGUILayout.PropertyField(m_PropTintAllSprites, Styles.tintAllSpritesLabel);

            EditorGUILayout.PropertyField(m_PropParseEscapeCharacters, Styles.parseEscapeCharactersLabel);

            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // SPRITE ASSET
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.defaultSpriteAssetLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropSpriteAsset, Styles.defaultSpriteAssetLabel);
            EditorGUILayout.PropertyField(m_PropEnableEmojiSupport, Styles.enableEmojiSupportLabel);
            EditorGUILayout.PropertyField(m_PropSpriteAssetPath, Styles.spriteAssetsPathLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // STYLE SHEET
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.defaultStyleSheetLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_PropStyleSheet, Styles.defaultStyleSheetLabel);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                TMP_StyleSheet.UpdateStyleSheet();
            }
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // COLOR GRADIENT PRESETS
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.colorGradientPresetsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropColorGradientPresetsPath, Styles.colorGradientsPathLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // LINE BREAKING RULE
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.lineBreakingLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropLeadingCharacters);
            EditorGUILayout.PropertyField(m_PropFollowingCharacters);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            if (serializedObject.ApplyModifiedProperties())
            {
                EditorUtility.SetDirty(target);
                TMPro_EventManager.ON_TMP_SETTINGS_CHANGED();
            }
        }
コード例 #10
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            string evt_cmd = Event.current.commandName;

            float labelWidth = EditorGUIUtility.labelWidth;
            float fieldWidth = EditorGUIUtility.fieldWidth;

            // TextMeshPro Font Info Panel
            EditorGUI.indentLevel = 0;

            // FONT ASSET
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.defaultFontAssetLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropFontAsset, Styles.defaultFontAssetLabel);
            EditorGUILayout.PropertyField(m_PropDefaultFontAssetPath, Styles.defaultFontAssetPathLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // FALLBACK FONT ASSETs
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.fallbackFontAssetsLabel, EditorStyles.boldLabel);
            m_List.DoLayoutList();

            GUILayout.Label(Styles.fallbackMaterialSettingsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropMatchMaterialPreset, Styles.matchMaterialPresetLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // MISSING GLYPHS
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.dynamicFontSystemSettingsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_GetFontFeaturesAtRuntime, Styles.getFontFeaturesAtRuntime);
            EditorGUILayout.PropertyField(m_PropMissingGlyphCharacter, Styles.missingGlyphLabel);
            EditorGUILayout.PropertyField(m_PropWarningsDisabled, Styles.disableWarningsLabel);
            //EditorGUILayout.PropertyField(m_DynamicAtlasTextureManager, Styles.dynamicAtlasTextureManager);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // TEXT OBJECT DEFAULT PROPERTIES
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.containerDefaultSettingsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;

            EditorGUILayout.PropertyField(m_PropDefaultTextMeshProTextContainerSize, Styles.textMeshProLabel);
            EditorGUILayout.PropertyField(m_PropDefaultTextMeshProUITextContainerSize, Styles.textMeshProUiLabel);
            EditorGUILayout.PropertyField(m_PropEnableRaycastTarget, Styles.enableRaycastTarget);
            EditorGUILayout.PropertyField(m_PropAutoSizeTextContainer, Styles.autoSizeContainerLabel);
            EditorGUILayout.PropertyField(m_PropIsTextObjectScaleStatic, Styles.isTextObjectScaleStaticLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();

            GUILayout.Label(Styles.textComponentDefaultSettingsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropDefaultFontSize, Styles.defaultFontSize);

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel(Styles.autoSizeRatioLabel);
                EditorGUIUtility.labelWidth = 32;
                EditorGUIUtility.fieldWidth = 10;

                EditorGUI.indentLevel = 0;
                EditorGUILayout.PropertyField(m_PropDefaultAutoSizeMinRatio, Styles.minLabel);
                EditorGUILayout.PropertyField(m_PropDefaultAutoSizeMaxRatio, Styles.maxLabel);
                EditorGUI.indentLevel = 1;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUIUtility.labelWidth = labelWidth;
            EditorGUIUtility.fieldWidth = fieldWidth;

            EditorGUILayout.PropertyField(m_PropWordWrapping, Styles.wordWrappingLabel);
            EditorGUILayout.PropertyField(m_PropKerning, Styles.kerningLabel);

            EditorGUILayout.PropertyField(m_PropExtraPadding, Styles.extraPaddingLabel);
            EditorGUILayout.PropertyField(m_PropTintAllSprites, Styles.tintAllSpritesLabel);

            EditorGUILayout.PropertyField(m_PropParseEscapeCharacters, Styles.parseEscapeCharactersLabel);

            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // SPRITE ASSET
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.defaultSpriteAssetLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropSpriteAsset, Styles.defaultSpriteAssetLabel);
            EditorGUILayout.PropertyField(m_PropMissingSpriteCharacterUnicode, Styles.missingSpriteCharacterUnicodeLabel);
            EditorGUILayout.PropertyField(m_PropEnableEmojiSupport, Styles.enableEmojiSupportLabel);
            //EditorGUILayout.PropertyField(m_PropSpriteRelativeScaling, Styles.spriteRelativeScale);
            EditorGUILayout.PropertyField(m_PropSpriteAssetPath, Styles.spriteAssetsPathLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // STYLE SHEET
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.defaultStyleSheetLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_PropStyleSheet, Styles.defaultStyleSheetLabel);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();

                TMP_StyleSheet styleSheet = m_PropStyleSheet.objectReferenceValue as TMP_StyleSheet;
                if (styleSheet != null)
                {
                    styleSheet.RefreshStyles();
                }
            }
            EditorGUILayout.PropertyField(m_PropStyleSheetsResourcePath, Styles.styleSheetResourcePathLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // COLOR GRADIENT PRESETS
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.colorGradientPresetsLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropColorGradientPresetsPath, Styles.colorGradientsPathLabel);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            // LINE BREAKING RULE
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(Styles.lineBreakingLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(m_PropLeadingCharacters);
            EditorGUILayout.PropertyField(m_PropFollowingCharacters);

            EditorGUILayout.Space();
            GUILayout.Label(Styles.koreanSpecificRules, EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(m_PropUseModernHangulLineBreakingRules, new GUIContent("Use Modern Line Breaking", "Determines if traditional or modern line breaking rules will be used to control line breaking. Traditional line breaking rules use the Leading and Following Character rules whereas Modern uses spaces for line breaking."));

            EditorGUI.indentLevel = 0;

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            if (serializedObject.ApplyModifiedProperties() || evt_cmd == k_UndoRedo)
            {
                EditorUtility.SetDirty(target);
                TMPro_EventManager.ON_TMP_SETTINGS_CHANGED();
            }
        }
コード例 #11
0
        public override void OnInspectorGUI()
        {
            Event current = Event.current;

            base.serializedObject.Update();
            GUILayout.Label("<b>TextMeshPro - Style Sheet</b>", TMP_UIStyleManager.Section_Label);
            int arraySize = m_styleList_prop.arraySize;
            int num       = (Screen.height - 178) / 111;

            if (arraySize > 0)
            {
                for (int i = num * m_page; i < arraySize && i < num * (m_page + 1); i++)
                {
                    if (m_selectedElement == i)
                    {
                        EditorGUI.DrawRect(m_selectionRect, new Color32(40, 192, byte.MaxValue, byte.MaxValue));
                    }
                    Rect rect = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));
                    EditorGUILayout.BeginVertical(TMP_UIStyleManager.Group_Label);
                    SerializedProperty arrayElementAtIndex = m_styleList_prop.GetArrayElementAtIndex(i);
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(arrayElementAtIndex);
                    EditorGUILayout.EndVertical();
                    if (EditorGUI.EndChangeCheck())
                    {
                    }
                    Rect rect2         = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));
                    Rect selectionArea = new Rect(rect.x, rect.y, rect2.width, rect2.y - rect.y);
                    if (DoSelectionCheck(selectionArea))
                    {
                        m_selectedElement = i;
                        m_selectionRect   = new Rect(selectionArea.x - 2f, selectionArea.y + 2f, selectionArea.width + 4f, selectionArea.height - 4f);
                        Repaint();
                    }
                }
            }
            int num2 = (!current.shift) ? 1 : 10;

            GUILayout.Space(-3f);
            Rect controlRect = EditorGUILayout.GetControlRect(false, 20f);

            controlRect.width /= 6f;
            if (num == 0)
            {
                return;
            }
            controlRect.x += controlRect.width * 4f;
            if (GUI.Button(controlRect, "+"))
            {
                m_styleList_prop.arraySize++;
                base.serializedObject.ApplyModifiedProperties();
                TMP_StyleSheet.RefreshStyles();
            }
            controlRect.x += controlRect.width;
            if (m_selectedElement == -1)
            {
                GUI.enabled = false;
            }
            if (GUI.Button(controlRect, "-"))
            {
                if (m_selectedElement != -1)
                {
                    m_styleList_prop.DeleteArrayElementAtIndex(m_selectedElement);
                }
                m_selectedElement = -1;
                base.serializedObject.ApplyModifiedProperties();
                TMP_StyleSheet.RefreshStyles();
            }
            GUILayout.Space(5f);
            controlRect        = EditorGUILayout.GetControlRect(false, 20f);
            controlRect.width /= 3f;
            if (m_page > 0)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }
            if (GUI.Button(controlRect, "Previous"))
            {
                m_page -= num2;
            }
            GUI.enabled    = true;
            controlRect.x += controlRect.width;
            int num3 = (int)((float)arraySize / (float)num + 0.999f);

            GUI.Label(controlRect, "Page " + (m_page + 1) + " / " + num3, GUI.skin.button);
            controlRect.x += controlRect.width;
            if (num * (m_page + 1) < arraySize)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }
            if (GUI.Button(controlRect, "Next"))
            {
                m_page += num2;
            }
            m_page = Mathf.Clamp(m_page, 0, arraySize / num);
            if (base.serializedObject.ApplyModifiedProperties())
            {
                TMPro_EventManager.ON_TEXT_STYLE_PROPERTY_CHANGED(true);
            }
            GUI.enabled = true;
            if (current.type == EventType.MouseDown && current.button == 0)
            {
                m_selectedElement = -1;
            }
        }