internal bool Populate_Internal(
            string str, Font font, Color color,
            int fontSize, float scaleFactor, float lineSpacing, FontStyle style, bool richText,
            bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize,
            VerticalWrapMode verticalOverFlow, HorizontalWrapMode horizontalOverflow, bool updateBounds,
            TextAnchor anchor, Vector2 extents, Vector2 pivot, bool generateOutOfBounds, bool alignByGeometry,
            out TextGenerationError error)
        {
            if (font == null)
            {
                error = TextGenerationError.NoFont;
                return(false);
            }

            uint uerror = 0;
            bool res    = Populate_Internal(
                str, font, color,
                fontSize, scaleFactor, lineSpacing, style, richText,
                resizeTextForBestFit, resizeTextMinSize, resizeTextMaxSize,
                (int)verticalOverFlow, (int)horizontalOverflow, updateBounds,
                anchor, extents.x, extents.y, pivot.x, pivot.y, generateOutOfBounds, alignByGeometry, out uerror);

            error = (TextGenerationError)uerror;
            return(res);
        }
Пример #2
0
        public void Init(InputField input, Color color, Font font, Func <string, Sprite> loadFace,
                         int emojiSize = 30, int fontSize = 18, VerticalWrapMode verticalWrapMode = VerticalWrapMode.Overflow)
        {
            _input = input;
            _input.onValueChanged.AddListener(OnTextChange);
            _backText = string.Empty;
            _showText = string.Empty;
            GameObject go = new GameObject("TextPic");

            _textPic = go.AddComponent <TextPic>();
            _textPic.InitTextPic(color, font, loadFace, emojiSize, fontSize, verticalWrapMode);

            Vector2 newSize = _input.transform.Find("Text").GetComponent <RectTransform>().sizeDelta;
            float   newX    = newSize.x * 0.05f;

            newSize.x += newX;
            //可能需要自己设置宽高Text的锚点不在一个点上sizeDelta的大小不对
            _textPic.rectTransform.sizeDelta = newSize;
            _textPic.alignment = TextAnchor.MiddleLeft;
            _textPic.transform.SetParent(_input.transform);
            Vector2 newPos = Vector2.zero;

            newPos.x += newX * 0.5f;
            _textPic.rectTransform.anchoredPosition = newPos;
            _input.textComponent = _textPic;
        }
Пример #3
0
    internal void InitializeTextComponent(Font _font, FontStyle _fontStyle, int _fontSize, float _lineSpacing, bool _richText, TextAnchor _alignment,
                                          HorizontalWrapMode _horizontalOverflow, VerticalWrapMode _verticalOverflow, bool _bestFit, int _minSize, int _maxSize, Color32 _color,
                                          string _text, Property <string> _boundProperty = null)
    {
        Text = GameObject.GetComponent <UnityEngine.UI.Text>();
        if (Text == null)
        {
            Text = GameObject.AddComponent <UnityEngine.UI.Text>();
        }

        Text.font                 = _font;
        Text.fontStyle            = _fontStyle;
        Text.fontSize             = _fontSize;
        Text.lineSpacing          = _lineSpacing;
        Text.supportRichText      = true;
        Text.alignment            = _alignment;
        Text.horizontalOverflow   = _horizontalOverflow;
        Text.verticalOverflow     = _verticalOverflow;
        Text.resizeTextForBestFit = _bestFit;
        Text.resizeTextMinSize    = _minSize;
        Text.resizeTextMaxSize    = _maxSize;
        Text.color                = _color;

        Text.raycastTarget = false;

        BoundProperty = _boundProperty;
        if (BoundProperty != null)
        {
            BoundProperty.PropertyChangedEvent += OnPropertyChanged;
        }

        DefaultText = _text;

        UpdateTextComponent();
    }
Пример #4
0
 public void SetTextVerticalOverflow(VerticalWrapMode mode)
 {
     if (this.text != null)
     {
         this.text.verticalOverflow = mode;
     }
 }
Пример #5
0
 public TextSpec(
     string text                           = "",
     FontName?font                         = null,
     FontStyle fontStyle                   = FontStyle.Normal,
     int fontSize                          = 14,
     int lineSpacing                       = 1,
     bool shouldSupportRichText            = false,
     TextAnchor alignment                  = TextAnchor.UpperLeft,
     bool alignByGeometry                  = false,
     HorizontalWrapMode horizontalOverflow = HorizontalWrapMode.Wrap,
     VerticalWrapMode verticalOverflow     = VerticalWrapMode.Truncate,
     bool resizeTextForBestFit             = false,
     Color?color                           = null,
     MaterialName?material                 = null,
     bool isRaycastTarget                  = true)
 {
     Text                  = text;
     Font                  = font;
     FontStyle             = fontStyle;
     FontSize              = fontSize;
     LineSpacing           = lineSpacing;
     ShouldSupportRichText = shouldSupportRichText;
     Alignment             = alignment;
     AlignByGeometry       = alignByGeometry;
     HorizontalOverflow    = horizontalOverflow;
     VerticalOverflow      = verticalOverflow;
     ResizeTextForBestFit  = resizeTextForBestFit;
     Color                 = color.GetValueOrDefault(Color.white);
     Material              = material;
     IsRaycastTarget       = isRaycastTarget;
 }
Пример #6
0
    protected override void GUI()
    {
        base.GUI();

        Font               font               = Data.DefaultFont;
        FontStyle          fontStyle          = Data.DefaultFontStyle;
        int                fontSize           = Data.DefaultFontSize;
        int                lineSpacing        = Data.DefaultLineSpacing;
        TextAnchor         textAnchor         = Data.DefaultTextAnchor;
        bool               isGeometry         = Data.IsDefaultGeometry;
        HorizontalWrapMode horizontalWrapMode = Data.DefaultHorizontalWrapMode;
        VerticalWrapMode   verticalWrapMode   = Data.DefaultVerticalWrapMode;
        bool               isBestFit          = Data.IsDefaultBestFit;
        Color              fontColor          = Data.DefaultFontColor;

        switch (Type)
        {
        case TextType.Default:
            break;
        }

        text.font                 = font;
        text.fontStyle            = fontStyle;
        text.fontSize             = fontSize;
        text.lineSpacing          = lineSpacing;
        text.alignment            = textAnchor;
        text.alignByGeometry      = isGeometry;
        text.horizontalOverflow   = horizontalWrapMode;
        text.verticalOverflow     = verticalWrapMode;
        text.resizeTextForBestFit = isBestFit;
        text.color                = fontColor;
    }
Пример #7
0
        public UIText(string text, float x, float y, int fontsize, Color color,
                      TextAnchor alignment,
                      HorizontalWrapMode horizontalOverflow, VerticalWrapMode verticalOverflow)
        {
#if UNITY_EDITOR
            Name = "Text";
#endif
            this.textComponent = gameObject.AddComponent <Text>();
            this.textComponent.raycastTarget = false;

            if (FontManager.DefaultFont == null)
            {
                Debug.LogWarning("DefaultFont is null, please call \"FontManager.SetDefaultFont()\" first");
            }

            this.Font               = FontManager.DefaultFont;
            this.FontSize           = fontsize;
            this.Colour             = color;
            this.Alignment          = alignment;
            this.HorizontalOverflow = horizontalOverflow;
            this.VerticalOverflow   = verticalOverflow;
            this.SupportRichText    = false;
            this.Text               = text; //这行代码必须放在HorizontalOverflow VerticalOverflow赋值之后

            SetAnchor(alignment);

            SetPosition(x, y);
        }
Пример #8
0
    static int IntToEnum(IntPtr L)
    {
        int arg0           = (int)LuaDLL.lua_tonumber(L, 1);
        VerticalWrapMode o = (VerticalWrapMode)arg0;

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Пример #9
0
    private TextOverflowModes GetOverflowMode(VerticalWrapMode verticalOverflow)
    {
        if (verticalOverflow == VerticalWrapMode.Truncate)
        {
            return(TextOverflowModes.Truncate);
        }

        return(TextOverflowModes.Overflow);
    }
Пример #10
0
        public ITextComponent SetTextVerticalOverflow(VerticalWrapMode mode)
        {
            if (this.text != null)
            {
                this.text.verticalOverflow = mode;
            }

            return(this);
        }
Пример #11
0
        private TextOverflowModes GetTMPVerticalOverflow(VerticalWrapMode verticalOverflow, HorizontalWrapMode horizontalOverflow)
        {
            if (alwaysUseOverflowForNonWrappingTexts && horizontalOverflow == HorizontalWrapMode.Overflow)
            {
                return(TextOverflowModes.Overflow);
            }

            return(verticalOverflow == VerticalWrapMode.Overflow ? TextOverflowModes.Overflow : TextOverflowModes.Truncate);
        }
Пример #12
0
        public static void SetTextVerticalOverflow(MaskableGraphic text, VerticalWrapMode mode)
        {
            var instance = text as Text;

            if (instance != null)
            {
                instance.verticalOverflow = mode;
            }
        }
Пример #13
0
 public void InitTextPic(Color color, Font font, Func <string, Sprite> loadFace, int emojiSize, int fontSize = 18, VerticalWrapMode verticalWrapMode = VerticalWrapMode.Truncate)
 {
     this.font        = font;
     this.fontSize    = fontSize;
     _emojiSize       = emojiSize;
     this.color       = color;
     _loadFace        = loadFace;
     verticalOverflow = verticalWrapMode;
 }
 public static void SetTextVerticalOverflow(MaskableGraphic text, VerticalWrapMode mode)
 {
                 #if TEXTMESHPRO_SUPPORTED
     var instance = text as TMPro.TMP_Text;
     if (instance != null)
     {
         instance.overflowMode = (mode == VerticalWrapMode.Overflow ? TMPro.TextOverflowModes.Overflow : TMPro.TextOverflowModes.Truncate);
     }
                 #endif
 }
Пример #15
0
 public ParagraphSettings(TextAnchor alignment         = TextAnchor.UpperLeft,
                          HorizontalWrapMode hOverflow = HorizontalWrapMode.Wrap,
                          VerticalWrapMode vOverflow   = VerticalWrapMode.Truncate,
                          bool bestFit = false, bool alignByGeometry = false)
 {
     this.alignment          = alignment;
     this.horizontalOverflow = hOverflow;
     this.verticalOverflow   = vOverflow;
     this.bestFit            = bestFit;
     this.alignByGeometry    = alignByGeometry;
 }
Пример #16
0
            public ParagraphSettings(Text text)
            {
                if (text == null)
                {
                    NullTextAlert();
                }

                this.alignment          = text.alignment;
                this.horizontalOverflow = text.horizontalOverflow;
                this.verticalOverflow   = text.verticalOverflow;
                this.bestFit            = text.resizeTextForBestFit;
                this.alignByGeometry    = text.alignByGeometry;
            }
Пример #17
0
            public ParagraphSettings(ParagraphSettings toCopy)
            {
                if (toCopy == null)
                {
                    NullCopyAlert();
                }

                this.alignment          = toCopy.alignment;
                this.horizontalOverflow = toCopy.horizontalOverflow;
                this.verticalOverflow   = toCopy.verticalOverflow;
                this.bestFit            = toCopy.bestFit;
                this.alignByGeometry    = toCopy.alignByGeometry;
            }
Пример #18
0
        public ITextComponent SetTextVerticalOverflow(VerticalWrapMode mode)
        {
            if (TextComponentUGUIAddon.IsValid(this.text) == true)
            {
                TextComponentUGUIAddon.SetTextVerticalOverflow(this.text, mode);
            }
            if (TextComponentTMPAddon.IsValid(this.text) == true)
            {
                TextComponentTMPAddon.SetTextVerticalOverflow(this.text, mode);
            }

            return(this);
        }
Пример #19
0
 protected override void Collect(Text t)
 {
     text = t.text;
     //font = t.font;
     fontSize             = t.fontSize;
     fontStyle            = t.fontStyle;
     lineSpacing          = t.lineSpacing;
     supportRichText      = t.supportRichText;
     alignment            = t.alignment;
     alignByGeometry      = t.alignByGeometry;
     horizontalOverflow   = t.horizontalOverflow;
     verticalOverflow     = t.verticalOverflow;
     resizeTextForBestFit = t.resizeTextForBestFit;
     maskable             = t.maskable;
 }
Пример #20
0
 void Start()
 {
     invertMat = new Material(Shader.Find("GrabPassInvert"));
     if (invertMat == null)
     {
         Debug.Log("no material!");
     }
     text           = transform.GetComponent <Text>();
     orignalMat     = text.material;
     originColor    = text.color;
     originStyle    = text.fontStyle;
     originFont     = text.font;
     originSize     = text.fontSize;
     originalOFMode = text.verticalOverflow;
     originFont     = text.font;
 }
Пример #21
0
 public TextSerializable(Text text) : base(text)
 {
     alignment            = text.alignment;
     alignByGeometry      = text.alignByGeometry;
     fontSize             = text.fontSize;
     horizontalOverflow   = text.horizontalOverflow;
     verticalOverflow     = text.verticalOverflow;
     lineSpacing          = text.lineSpacing;
     resizeTextMaxSize    = text.resizeTextMaxSize;
     fontStyle            = text.fontStyle;
     resizeTextMinSize    = text.resizeTextMinSize;
     supportRichText      = text.supportRichText;
     resizeTextForBestFit = text.resizeTextForBestFit;
     font      = text.font != null ? new FontSerializable(text.font) : null;
     this.text = text.text;
 }
Пример #22
0
    void Start()
    {
        text         = transform.parent.GetComponent <Text>();
        originColor  = text.color;
        originStyle  = text.fontStyle;
        originSize   = text.fontSize;
        overflowMode = text.verticalOverflow;

        img = text.transform.parent.GetComponent <Image>();
        if (img != null && img.enabled)
        {
            whetherPanel = true;
        }
        else
        {
            whetherPanel = false;
        }
    }
    private static int get_verticalOverflow(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            Text             text             = (Text)obj;
            VerticalWrapMode verticalOverflow = text.get_verticalOverflow();
            ToLua.Push(L, verticalOverflow);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.get_Message() : "attempt to index verticalOverflow on a nil value");
        }
        return(result);
    }
    private static int set_verticalOverflow(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            Text             text             = (Text)obj;
            VerticalWrapMode verticalOverflow = (int)ToLua.CheckObject(L, 2, typeof(VerticalWrapMode));
            text.set_verticalOverflow(verticalOverflow);
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.get_Message() : "attempt to index verticalOverflow on a nil value");
        }
        return(result);
    }
        protected override void ReadFromImpl(object obj)
        {
            base.ReadFromImpl(obj);
            Text uo = (Text)obj;

            font                 = ToID(uo.font);
            text                 = uo.text;
            supportRichText      = uo.supportRichText;
            resizeTextForBestFit = uo.resizeTextForBestFit;
            resizeTextMinSize    = uo.resizeTextMinSize;
            resizeTextMaxSize    = uo.resizeTextMaxSize;
            alignment            = uo.alignment;
            alignByGeometry      = uo.alignByGeometry;
            fontSize             = uo.fontSize;
            horizontalOverflow   = uo.horizontalOverflow;
            verticalOverflow     = uo.verticalOverflow;
            lineSpacing          = uo.lineSpacing;
            fontStyle            = uo.fontStyle;
        }
Пример #26
0
 public void assignFrom(TextSettings other)
 {
     fontMaterial    = other.fontMaterial;
     font            = other.font;
     pixelsPerUnit   = other.pixelsPerUnit;
     richText        = other.richText;
     alignByGeometry = other.alignByGeometry;
     textWidth       = other.textWidth;
     textHeight      = other.textHeight;
     fontSize        = other.fontSize;
     minDynamicSize  = other.minDynamicSize;
     maxDynamicSize  = other.maxDynamicSize;
     anchor          = other.anchor;
     alignment       = other.alignment;
     color           = other.color;
     bestFit         = other.bestFit;
     lineSpacing     = other.lineSpacing;
     horizontalWrap  = other.horizontalWrap;
     verticalWrap    = other.verticalWrap;
     fontStyle       = other.fontStyle;
 }
        private void ReplaceOldTextWithNew(Text source)
        {
            // Grab all the old information first
            GameObject         parentObject   = source.gameObject;
            string             text           = source.text;
            FontStyle          fontStyle      = source.fontStyle;
            float              fontSize       = source.fontSize;
            float              lineSpacing    = source.lineSpacing;
            bool               richText       = source.supportRichText;
            TextAnchor         alignment      = source.alignment;
            HorizontalWrapMode horizontalMode = source.horizontalOverflow;
            VerticalWrapMode   verticalMode   = source.verticalOverflow;
            bool               isAutoSizing   = source.resizeTextForBestFit;
            float              minFontSize    = source.resizeTextMinSize;
            float              maxFontSize    = source.resizeTextMaxSize;
            Color              fontColor      = source.color;
            bool               rayCastTarget  = source.raycastTarget;

            // Grab transform information
            RectTransform transform      = source.GetComponent <RectTransform>();
            Vector3       anchorPosition = transform.anchoredPosition3D;
            Vector2       anchorMax      = transform.anchorMax;
            Vector2       anchorMin      = transform.anchorMin;
            Vector2       offsetMax      = transform.offsetMax;
            Vector2       offsetMin      = transform.offsetMin;

            // Destroy the old component
            DestroyImmediate(source);

            // Add the new text component
            TextMeshProUGUI newText = parentObject.AddComponent <TextMeshProUGUI>();

            // Copy the old text properties into the new text
            newText.text        = text;
            newText.font        = newFont;
            newText.fontStyle   = ConvertFontStyle(fontStyle);
            newText.fontSize    = fontSize;
            newText.lineSpacing = lineSpacing;
            newText.richText    = richText;
            newText.alignment   = ConvertAlignment(alignment);

            // Setup word wrapping
            newText.enableWordWrapping = (horizontalMode == HorizontalWrapMode.Wrap);

            // Setup overflow
            TextOverflowModes overflowMode = TextOverflowModes.Overflow;

            if (verticalMode == VerticalWrapMode.Truncate)
            {
                overflowMode = TextOverflowModes.Truncate;
            }
            newText.overflowMode = overflowMode;

            // Setup the rest of the properties
            newText.enableAutoSizing = isAutoSizing;
            newText.fontSizeMin      = minFontSize;
            newText.fontSizeMax      = maxFontSize;
            newText.color            = fontColor;
            newText.raycastTarget    = rayCastTarget;

            // Revert transform information
            transform.anchoredPosition3D = anchorPosition;
            transform.anchorMax          = anchorMax;
            transform.anchorMin          = anchorMin;
            transform.offsetMax          = offsetMax;
            transform.offsetMin          = offsetMin;
        }
Пример #28
0
 internal bool Populate_Internal(string str, Font font, Color color, int fontSize, float scaleFactor, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, VerticalWrapMode verticalOverFlow, HorizontalWrapMode horizontalOverflow, bool updateBounds, TextAnchor anchor, Vector2 extents, Vector2 pivot, bool generateOutOfBounds, bool alignByGeometry, out TextGenerationError error)
 {
     uint num = 0;
     bool flag = this.Populate_Internal_cpp(str, font, color, fontSize, scaleFactor, lineSpacing, style, richText, resizeTextForBestFit, resizeTextMinSize, resizeTextMaxSize, (int) verticalOverFlow, (int) horizontalOverflow, updateBounds, anchor, extents.x, extents.y, pivot.x, pivot.y, generateOutOfBounds, alignByGeometry, out num);
     error = (TextGenerationError) num;
     return flag;
 }
			public void SetTextVerticalOverflow(VerticalWrapMode mode) {
				
				if (this.text != null) this.text.verticalOverflow = mode;
				
			}
Пример #30
0
		public ITextComponent SetTextVerticalOverflow(VerticalWrapMode mode) {
			
			if (this.text != null) this.text.verticalOverflow = mode;

			return this;

		}
Пример #31
0
		internal bool Populate_Internal(string str, Font font, Color color, int fontSize, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, VerticalWrapMode verticalOverFlow, HorizontalWrapMode horizontalOverflow, bool updateBounds, TextAnchor anchor, Vector2 extents, Vector2 pivot, bool generateOutOfBounds)
		{
			return this.Populate_Internal_cpp(str, font, color, fontSize, lineSpacing, style, richText, resizeTextForBestFit, resizeTextMinSize, resizeTextMaxSize, (int)verticalOverFlow, (int)horizontalOverflow, updateBounds, anchor, extents.x, extents.y, pivot.x, pivot.y, generateOutOfBounds);
		}
Пример #32
0
 /// <summary>
 /// Set the vertical overflow mode of this Text object with the passed in value.
 /// </summary>
 public static void SetVerticalOverflow(this Text t, VerticalWrapMode verticalOverflow)
 {
     t.verticalOverflow = verticalOverflow;
 }
Пример #33
0
 internal bool Populate_Internal(string str, Font font, Color color, int fontSize, float scaleFactor, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, VerticalWrapMode verticalOverFlow, HorizontalWrapMode horizontalOverflow, bool updateBounds, TextAnchor anchor, Vector2 extents, Vector2 pivot, bool generateOutOfBounds, bool alignByGeometry)
 {
     return(this.Populate_Internal_cpp(str, font, color, fontSize, scaleFactor, lineSpacing, style, richText, resizeTextForBestFit, resizeTextMinSize, resizeTextMaxSize, (int)verticalOverFlow, (int)horizontalOverflow, updateBounds, anchor, extents.x, extents.y, pivot.x, pivot.y, generateOutOfBounds, alignByGeometry));
 }
Пример #34
0
    public static void TextMeshProFontChange()
    {
        try
        {
            string fontPath = "Assets/Res/Gui/Font/FZLTCH.TTF";
            var    font     = AssetDatabase.LoadAssetAtPath <Font>(fontPath);
            if (font == null)
            {
                Debug.Log("字体 FZLTCH.TTF 不存在");
                return;
            }

            var sele = Selection.objects;
            for (int i = 0; i < sele.Length; i++)
            {
                var assetPath = AssetDatabase.GetAssetPath(sele[i]);
                EditorUtility.DisplayProgressBar("Hold On...", assetPath, (i + 1) * 1f / sele.Length);
                GameObject instanceObj = PrefabUtility.LoadPrefabContents(assetPath);
                var        meshTexts   = instanceObj.GetComponentsInChildren <TMPro.TextMeshProUGUI>(true);

                foreach (var meshText in meshTexts)
                {
                    if (meshText.font == null)
                    {
                        // Debug.LogError("丢字体。。" + assetPath + "  " + meshText.gameObject.name);
                        continue;
                    }
                    if (meshText.font.name.Equals("JDJZONGYI SDF"))
                    {
                        if (meshText.gameObject.GetComponentInParent <TMPro.TMP_InputField>() != null)
                        {
                            Debug.LogError("需要手动替换为InputField" + assetPath);
                        }
                        Debug.Log(meshText.gameObject.name);

                        var msg = meshText.text;

                        var fontsize        = meshText.fontSize;
                        var sp              = meshText.lineSpacing;
                        var fontstyle       = meshText.fontStyle;
                        var fontAutoSize    = meshText.autoSizeTextContainer;
                        var fontVertexColor = meshText.color;
                        var alignment       = meshText.alignment;
                        var raycast         = meshText.raycastTarget;
                        var richText        = meshText.richText;
                        var obj             = meshText.gameObject;
                        GameObject.DestroyImmediate(meshText);
                        if (obj.GetComponent <UnityEngine.UI.Text>() != null)
                        {
                            Debug.LogError("已经存在Text 组件,请手动查看是否需要添加" + assetPath);
                            continue;
                        }
                        var tx = obj.AddComponent <UnityEngine.UI.Text>();
                        tx.text        = msg;
                        tx.font        = font;
                        tx.fontStyle   = (FontStyle)(fontsize > 2 ? 0 : fontsize);
                        tx.fontSize    = (int)fontsize;
                        tx.lineSpacing = sp > 1f ? 1f + (float)System.Math.Round(sp / fontsize, 2) : 1f;
                        var unityAligment = TextAnchor.UpperLeft;

                        Debug.Log(alignment);
                        if (alignment == TMPro.TextAlignmentOptions.TopLeft)
                        {
                            unityAligment = TextAnchor.UpperLeft;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.TopRight)
                        {
                            unityAligment = TextAnchor.UpperRight;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.MidlineLeft)
                        {
                            unityAligment = TextAnchor.MiddleLeft;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.MidlineRight)
                        {
                            unityAligment = TextAnchor.MiddleRight;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.MidlineJustified)  //left middle
                        {
                            unityAligment = TextAnchor.MiddleLeft;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.Center)  // center middle
                        {
                            unityAligment = TextAnchor.MiddleCenter;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.Left)  //left middle
                        {
                            unityAligment = TextAnchor.MiddleLeft;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.Right)  //right middle
                        {
                            unityAligment = TextAnchor.MiddleRight;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.Midline) //center middle
                        {
                            unityAligment = TextAnchor.MiddleCenter;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.Top)   //center top
                        {
                            unityAligment = TextAnchor.UpperCenter;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.BottomLeft ||
                                 alignment == TMPro.TextAlignmentOptions.BottomJustified)
                        {
                            unityAligment = TextAnchor.LowerLeft;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.BottomRight)
                        {
                            unityAligment = TextAnchor.LowerRight;
                        }
                        else if (alignment == TMPro.TextAlignmentOptions.Bottom)
                        {
                            unityAligment = TextAnchor.LowerCenter;
                        }
                        else
                        {
                            Debug.LogError("Text Mesh Pro UGUI 存在未知文本对齐方式,请手动调整");
                        }
                        tx.alignment = unityAligment;
                        var overflow           = meshText.overflowMode;
                        var wrap               = meshText.enableWordWrapping;
                        HorizontalWrapMode hOv = HorizontalWrapMode.Overflow;
                        VerticalWrapMode   vOv = VerticalWrapMode.Overflow;
                        //水平
                        hOv = wrap == true ? HorizontalWrapMode.Wrap : HorizontalWrapMode.Overflow;

                        //垂直
                        if (overflow == TMPro.TextOverflowModes.Overflow)
                        {
                            vOv = VerticalWrapMode.Overflow;
                        }
                        else if (overflow == TMPro.TextOverflowModes.Masking)
                        {
                            vOv = VerticalWrapMode.Overflow;
                        }
                        else if (overflow == TMPro.TextOverflowModes.Truncate)
                        {
                            vOv = VerticalWrapMode.Truncate;
                        }
                        else if (overflow == TMPro.TextOverflowModes.Ellipsis)
                        {
                            vOv = VerticalWrapMode.Truncate;
                        }
                        else if (overflow == TMPro.TextOverflowModes.ScrollRect)
                        {
                            vOv = VerticalWrapMode.Overflow;
                        }

                        tx.horizontalOverflow = hOv;
                        tx.verticalOverflow   = vOv;
                        tx.color           = fontVertexColor;
                        tx.raycastTarget   = raycast;
                        tx.supportRichText = richText;
                    }
                }
                PrefabUtility.SaveAsPrefabAsset(instanceObj, assetPath);
                PrefabUtility.UnloadPrefabContents(instanceObj);
            }

            EditorUtility.ClearProgressBar();
            Debug.Log("完成");
        }
        catch (System.Exception e)
        {
            Debug.Log(e.ToString());
        }
    }