Пример #1
0
        internal TextInfo Update(MeshGenerationContextUtils.TextParams parms, float pixelsPerPoint)
        {
            parms.rect = new Rect(Vector2.zero, parms.rect.size);
            int      hashCode = parms.GetHashCode();
            bool     flag     = this.m_PreviousGenerationSettingsHash == hashCode;
            TextInfo textInfo;

            if (flag)
            {
                textInfo = this.textInfo;
            }
            else
            {
                TextHandle.UpdateGenerationSettingsCommon(parms, this.m_CurrentGenerationSettings);
                this.m_CurrentGenerationSettings.color        = parms.fontColor;
                this.m_CurrentGenerationSettings.inverseYAxis = true;
                this.m_CurrentGenerationSettings.scale        = pixelsPerPoint;
                this.m_CurrentGenerationSettings.overflowMode = parms.textOverflowMode;
                this.textInfo.isDirty = true;
                UnityEngine.TextCore.TextGenerator.GenerateText(this.m_CurrentGenerationSettings, this.textInfo);
                this.m_PreviousGenerationSettingsHash = hashCode;
                textInfo = this.textInfo;
            }
            return(textInfo);
        }
        private void OnAttachToPanel(AttachToPanelEvent e)
        {
            TextHandle textHandle = this.textHandle;

            textHandle.useLegacy = (e.destinationPanel.contextType == ContextType.Editor);
            this.textHandle      = textHandle;
        }
Пример #3
0
        public static TextHandle New()
        {
            TextHandle h = new TextHandle();

            h.m_TextInfo = new TextInfo();
            h.useLegacy  = false;
            h.m_CurrentGenerationSettings = new TextCore.TextGenerationSettings();
            h.m_CurrentLayoutSettings     = new TextCore.TextGenerationSettings();
            return(h);
        }
Пример #4
0
        private void UpdatePreferredValues(MeshGenerationContextUtils.TextParams parms)
        {
            parms.rect = new Rect(Vector2.zero, parms.rect.size);
            int  hashCode = parms.GetHashCode();
            bool flag     = this.m_PreviousLayoutSettingsHash == hashCode;

            if (!flag)
            {
                TextHandle.UpdateGenerationSettingsCommon(parms, this.m_CurrentLayoutSettings);
                this.m_PreferredSize = UnityEngine.TextCore.TextGenerator.GetPreferredValues(this.m_CurrentLayoutSettings, this.textInfo);
                this.m_PreviousLayoutSettingsHash = hashCode;
            }
        }
 protected TextInputBaseField(string label, int maxLength, char maskChar, TextInputBaseField <TValueType> .TextInputBase textInputBase)
 {
     this.< textHandle > k__BackingField = TextHandle.New();
     base..ctor(label, textInputBase);
     base.tabIndex       = 0;
     base.delegatesFocus = false;
     base.AddToClassList(TextInputBaseField <TValueType> .ussClassName);
     base.labelElement.AddToClassList(TextInputBaseField <TValueType> .labelUssClassName);
     base.visualInput.AddToClassList(TextInputBaseField <TValueType> .inputUssClassName);
     this.m_TextInputBase           = textInputBase;
     this.m_TextInputBase.maxLength = maxLength;
     this.m_TextInputBase.maskChar  = maskChar;
     base.RegisterCallback <AttachToPanelEvent>(new EventCallback <AttachToPanelEvent>(this.OnAttachToPanel), TrickleDown.NoTrickleDown);
 }
Пример #6
0
        private static void UpdateGenerationSettingsCommon(MeshGenerationContextUtils.TextParams painterParams, UnityEngine.TextCore.TextGenerationSettings settings)
        {
            settings.fontAsset = TextHandle.GetFontAsset(painterParams.font);
            settings.material  = settings.fontAsset.material;
            Rect rect = painterParams.rect;
            bool flag = float.IsNaN(rect.width);

            if (flag)
            {
                rect.width = painterParams.wordWrapWidth;
            }
            settings.screenRect    = rect;
            settings.text          = (string.IsNullOrEmpty(painterParams.text) ? " " : painterParams.text);
            settings.fontSize      = (float)((painterParams.fontSize > 0) ? painterParams.fontSize : painterParams.font.fontSize);
            settings.fontStyle     = TextGeneratorUtilities.LegacyStyleToNewStyle(painterParams.fontStyle);
            settings.textAlignment = TextGeneratorUtilities.LegacyAlignmentToNewAlignment(painterParams.anchor);
            settings.wordWrap      = painterParams.wordWrap;
            settings.richText      = false;
            settings.overflowMode  = TextOverflowMode.Overflow;
        }
Пример #7
0
 /// <summary>
 /// DO NOT USE MeasureVisualElementTextSize, use TextUtilities.MeasureVisualElementTextSize instead. This method is only there for backward compatibility reason and will soon be stripped.
 /// </summary>
 internal static Vector2 MeasureVisualElementTextSize(VisualElement ve, string textToMeasure, float width,
                                                      MeasureMode widthMode, float height, MeasureMode heightMode, TextHandle textHandle)
 {
     return(TextUtilities.MeasureVisualElementTextSize(ve, textToMeasure, width, widthMode, height, heightMode,
                                                       textHandle.textHandle));
 }
            internal void DrawWithTextSelectionAndCursor(MeshGenerationContext mgc, string newText, float pixelsPerPoint)
            {
                var playmodeTintColor = panel.contextType == ContextType.Editor
                    ? UIElementsUtility.editorPlayModeTintColor
                    : Color.white;

                var keyboardTextEditor = editorEventHandler as KeyboardTextEditorEventHandler;

                if (keyboardTextEditor == null)
                {
                    return;
                }

                keyboardTextEditor.PreDrawCursor(newText);

                int  cursorIndex   = editorEngine.cursorIndex;
                int  selectIndex   = editorEngine.selectIndex;
                Rect localPosition = editorEngine.localPosition;
                var  scrollOffset  = editorEngine.scrollOffset;

                float textScaling = TextHandle.ComputeTextScaling(worldTransform, pixelsPerPoint);

                var textParams = MeshGenerationContextUtils.TextParams.MakeStyleBased(this, text);

                textParams.text          = " ";
                textParams.wordWrapWidth = 0.0f;
                textParams.wordWrap      = false;

                float lineHeight = m_TextHandle.ComputeTextHeight(textParams, textScaling);

                float wordWrapWidth = 0.0f;

                // Make sure to take into account the word wrap style...
                if (editorEngine.multiline && (resolvedStyle.whiteSpace == WhiteSpace.Normal))
                {
                    wordWrapWidth = contentRect.width;

                    // Since the wrapping is enabled, there is no need to offset the text... It will always fit the space on screen !
                    scrollOffset = Vector2.zero;
                }

                Vector2 pos = editorEngine.graphicalCursorPos - scrollOffset;

                pos.y += lineHeight;
                GUIUtility.compositionCursorPos = this.LocalToWorld(pos);

                Color drawCursorColor = cursorColor;

                int selectionEndIndex = string.IsNullOrEmpty(GUIUtility.compositionString)
                    ? selectIndex
                    : cursorIndex + GUIUtility.compositionString.Length;

                CursorPositionStylePainterParameters cursorParams;

                // Draw highlighted section, if any
                if ((cursorIndex != selectionEndIndex) && !isDragging)
                {
                    int min = cursorIndex < selectionEndIndex ? cursorIndex : selectionEndIndex;
                    int max = cursorIndex > selectionEndIndex ? cursorIndex : selectionEndIndex;

                    cursorParams               = CursorPositionStylePainterParameters.GetDefault(this, text);
                    cursorParams.text          = editorEngine.text;
                    cursorParams.wordWrapWidth = wordWrapWidth;
                    cursorParams.cursorIndex   = min;

                    Vector2 minPos = m_TextHandle.GetCursorPosition(cursorParams, textScaling);

                    cursorParams.cursorIndex = max;
                    Vector2 maxPos = m_TextHandle.GetCursorPosition(cursorParams, textScaling);

                    minPos -= scrollOffset;
                    maxPos -= scrollOffset;

                    if (Mathf.Approximately(minPos.y, maxPos.y))
                    {
                        mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams()
                        {
                            rect              = new Rect(minPos.x, minPos.y, maxPos.x - minPos.x, lineHeight),
                            color             = selectionColor,
                            playmodeTintColor = playmodeTintColor
                        });
                    }
                    else
                    {
                        // Draw first line
                        mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams()
                        {
                            rect              = new Rect(minPos.x, minPos.y, contentRect.xMax - minPos.x, lineHeight),
                            color             = selectionColor,
                            playmodeTintColor = playmodeTintColor
                        });

                        var inbetweenHeight = (maxPos.y - minPos.y) - lineHeight;
                        if (inbetweenHeight > 0f)
                        {
                            // Draw all lines in-between
                            mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams()
                            {
                                rect              = new Rect(contentRect.xMin, minPos.y + lineHeight, contentRect.width, inbetweenHeight),
                                color             = selectionColor,
                                playmodeTintColor = playmodeTintColor
                            });
                        }

                        // Draw last line if not empty
                        if (maxPos.x != contentRect.x)
                        {
                            mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams()
                            {
                                rect              = new Rect(contentRect.xMin, maxPos.y, maxPos.x, lineHeight),
                                color             = selectionColor,
                                playmodeTintColor = playmodeTintColor
                            });
                        }
                    }
                }

                // Draw the text with the scroll offset
                if (!string.IsNullOrEmpty(editorEngine.text) && contentRect.width > 0.0f && contentRect.height > 0.0f)
                {
                    textParams      = MeshGenerationContextUtils.TextParams.MakeStyleBased(this, text);
                    textParams.rect = new Rect(contentRect.x - scrollOffset.x, contentRect.y - scrollOffset.y, contentRect.width + scrollOffset.x, contentRect.height + scrollOffset.y);
                    textParams.text = editorEngine.text;

                    mgc.Text(textParams, m_TextHandle, scaledPixelsPerPoint);
                }

                // Draw the cursor
                if (!isReadOnly && !isDragging)
                {
                    if (cursorIndex == selectionEndIndex && computedStyle.unityFont.value != null)
                    {
                        cursorParams               = CursorPositionStylePainterParameters.GetDefault(this, text);
                        cursorParams.text          = editorEngine.text;
                        cursorParams.wordWrapWidth = wordWrapWidth;
                        cursorParams.cursorIndex   = cursorIndex;

                        Vector2 cursorPosition = m_TextHandle.GetCursorPosition(cursorParams, textScaling);
                        cursorPosition -= scrollOffset;
                        mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams
                        {
                            rect              = new Rect(cursorPosition.x, cursorPosition.y, 1f, lineHeight),
                            color             = drawCursorColor,
                            playmodeTintColor = playmodeTintColor
                        });
                    }

                    // Draw alternate cursor, if any
                    if (editorEngine.altCursorPosition != -1)
                    {
                        cursorParams               = CursorPositionStylePainterParameters.GetDefault(this, text);
                        cursorParams.text          = editorEngine.text.Substring(0, editorEngine.altCursorPosition);
                        cursorParams.wordWrapWidth = wordWrapWidth;
                        cursorParams.cursorIndex   = editorEngine.altCursorPosition;

                        Vector2 altCursorPosition = m_TextHandle.GetCursorPosition(cursorParams, textScaling);
                        altCursorPosition -= scrollOffset;
                        mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams
                        {
                            rect              = new Rect(altCursorPosition.x, altCursorPosition.y, 1f, lineHeight),
                            color             = drawCursorColor,
                            playmodeTintColor = playmodeTintColor
                        });
                    }
                }

                keyboardTextEditor.PostDrawCursor();
            }
 public static void Text(this MeshGenerationContext mgc, TextParams textParams, TextHandle handle, float pixelsPerPoint)
 {
     if (textParams.font != null)
     {
         mgc.painter.DrawText(textParams, handle, pixelsPerPoint);
     }
 }
Пример #10
0
        internal static Vector2 MeasureVisualElementTextSize(VisualElement ve, string textToMeasure, float width, MeasureMode widthMode, float height, MeasureMode heightMode, TextHandle textHandle)
        {
            float measuredWidth  = float.NaN;
            float measuredHeight = float.NaN;

            Font usedFont = ve.computedStyle.unityFont.value;

            if (textToMeasure == null || usedFont == null)
            {
                return(new Vector2(measuredWidth, measuredHeight));
            }

            var elementScaling = ve.ComputeGlobalScale();

            float scaling = (elementScaling.x + elementScaling.y) * 0.5f * ve.scaledPixelsPerPoint;

            if (scaling <= 0)
            {
                return(Vector2.zero);
            }

            if (widthMode == MeasureMode.Exactly)
            {
                measuredWidth = width;
            }
            else
            {
                var textParams = GetTextSettings(ve, textToMeasure);
                textParams.wordWrap = false;
                textParams.richText = true;

                //we make sure to round up as yoga could decide to round down and text would start wrapping
                measuredWidth = Mathf.Ceil(textHandle.ComputeTextWidth(textParams, scaling));

                if (widthMode == MeasureMode.AtMost)
                {
                    measuredWidth = Mathf.Min(measuredWidth, width);
                }
            }

            if (heightMode == MeasureMode.Exactly)
            {
                measuredHeight = height;
            }
            else
            {
                var textParams = GetTextSettings(ve, textToMeasure);
                textParams.wordWrapWidth = measuredWidth;

                measuredHeight = Mathf.Ceil(textHandle.ComputeTextHeight(textParams, scaling));

                if (heightMode == MeasureMode.AtMost)
                {
                    measuredHeight = Mathf.Min(measuredHeight, height);
                }
            }

            return(new Vector2(measuredWidth, measuredHeight));
        }
Пример #11
0
        internal static Vector2 MeasureVisualElementTextSize(VisualElement ve, string textToMeasure, float width, VisualElement.MeasureMode widthMode, float height, VisualElement.MeasureMode heightMode, TextHandle textHandle)
        {
            float   num   = float.NaN;
            float   num2  = float.NaN;
            Font    value = ve.computedStyle.unityFont.value;
            bool    flag  = textToMeasure == null || value == null;
            Vector2 result;

            if (flag)
            {
                result = new Vector2(num, num2);
            }
            else
            {
                Vector3 vector = ve.ComputeGlobalScale();
                bool    flag2  = vector.x + vector.y <= 0f || ve.scaledPixelsPerPoint <= 0f;
                if (flag2)
                {
                    result = Vector2.zero;
                }
                else
                {
                    float scaledPixelsPerPoint = ve.scaledPixelsPerPoint;
                    float num3  = 0.02f;
                    float num4  = num3 / scaledPixelsPerPoint;
                    bool  flag3 = widthMode == VisualElement.MeasureMode.Exactly;
                    if (flag3)
                    {
                        num = width;
                    }
                    else
                    {
                        MeshGenerationContextUtils.TextParams textSettings = TextElement.GetTextSettings(ve, textToMeasure);
                        textSettings.wordWrap = false;
                        textSettings.richText = false;
                        num = textHandle.ComputeTextWidth(textSettings, scaledPixelsPerPoint);
                        num = ((num < num4) ? 0f : AlignmentUtils.CeilToPixelGrid(num, scaledPixelsPerPoint, num3));
                        bool flag4 = widthMode == VisualElement.MeasureMode.AtMost;
                        if (flag4)
                        {
                            num = Mathf.Min(num, width);
                        }
                    }
                    bool flag5 = heightMode == VisualElement.MeasureMode.Exactly;
                    if (flag5)
                    {
                        num2 = height;
                    }
                    else
                    {
                        MeshGenerationContextUtils.TextParams textSettings2 = TextElement.GetTextSettings(ve, textToMeasure);
                        textSettings2.wordWrapWidth = num;
                        textSettings2.richText      = false;
                        num2 = textHandle.ComputeTextHeight(textSettings2, scaledPixelsPerPoint);
                        num2 = ((num2 < num4) ? 0f : AlignmentUtils.CeilToPixelGrid(num2, scaledPixelsPerPoint, num3));
                        bool flag6 = heightMode == VisualElement.MeasureMode.AtMost;
                        if (flag6)
                        {
                            num2 = Mathf.Min(num2, height);
                        }
                    }
                    result = new Vector2(num, num2);
                }
            }
            return(result);
        }
Пример #12
0
        internal static Vector2 MeasureVisualElementTextSize(VisualElement ve, string textToMeasure, float width, MeasureMode widthMode, float height, MeasureMode heightMode, TextHandle textHandle)
        {
            float measuredWidth  = float.NaN;
            float measuredHeight = float.NaN;

            Font usedFont = ve.computedStyle.unityFont.value;

            if (textToMeasure == null || usedFont == null)
            {
                return(new Vector2(measuredWidth, measuredHeight));
            }

            var elementScaling = ve.ComputeGlobalScale();

            if (elementScaling.x + elementScaling.y <= 0 || ve.scaledPixelsPerPoint <= 0)
            {
                return(Vector2.zero);
            }

            float pixelsPerPoint = ve.scaledPixelsPerPoint;
            float pixelOffset    = 0.02f;
            float pointOffset    = pixelOffset / pixelsPerPoint;

            if (widthMode == MeasureMode.Exactly)
            {
                measuredWidth = width;
            }
            else
            {
                var textParams = GetTextSettings(ve, textToMeasure);
                textParams.wordWrap = false;
                textParams.richText = false;

                // Case 1215962: round up as yoga could decide to round down and text would start wrapping
                measuredWidth = textHandle.ComputeTextWidth(textParams, pixelsPerPoint);
                measuredWidth = measuredWidth < pointOffset ? 0 : AlignmentUtils.CeilToPixelGrid(measuredWidth, pixelsPerPoint, pixelOffset);

                if (widthMode == MeasureMode.AtMost)
                {
                    measuredWidth = Mathf.Min(measuredWidth, width);
                }
            }

            if (heightMode == MeasureMode.Exactly)
            {
                measuredHeight = height;
            }
            else
            {
                var textParams = GetTextSettings(ve, textToMeasure);
                textParams.wordWrapWidth = measuredWidth;
                textParams.richText      = false;

                measuredHeight = textHandle.ComputeTextHeight(textParams, pixelsPerPoint);
                measuredHeight = measuredHeight < pointOffset ? 0 : AlignmentUtils.CeilToPixelGrid(measuredHeight, pixelsPerPoint, pixelOffset);

                if (heightMode == MeasureMode.AtMost)
                {
                    measuredHeight = Mathf.Min(measuredHeight, height);
                }
            }

            return(new Vector2(measuredWidth, measuredHeight));
        }
Пример #13
0
 public UITKTextHandle(TextElement te)
 {
     m_CurrentGenerationSettings = new UnityEngine.TextCore.Text.TextGenerationSettings();
     textHandle    = new TextHandle();
     m_TextElement = te;
 }
Пример #14
0
        public static void Text(this MeshGenerationContext mgc, MeshGenerationContextUtils.TextParams textParams, TextHandle handle, float pixelsPerPoint)
        {
            bool flag = textParams.font != null;

            if (flag)
            {
                mgc.painter.DrawText(textParams, handle, pixelsPerPoint);
            }
        }
            internal void DrawWithTextSelectionAndCursor(MeshGenerationContext mgc, string newText, float pixelsPerPoint)
            {
                Color playmodeTintColor = (base.panel.contextType == ContextType.Editor) ? UIElementsUtility.editorPlayModeTintColor : Color.white;
                KeyboardTextEditorEventHandler keyboardTextEditorEventHandler = this.editorEventHandler as KeyboardTextEditorEventHandler;
                bool flag = keyboardTextEditorEventHandler == null;

                if (!flag)
                {
                    keyboardTextEditorEventHandler.PreDrawCursor(newText);
                    int     cursorIndex   = this.editorEngine.cursorIndex;
                    int     selectIndex   = this.editorEngine.selectIndex;
                    Rect    localPosition = this.editorEngine.localPosition;
                    Vector2 scrollOffset  = this.editorEngine.scrollOffset;
                    float   scaling       = TextHandle.ComputeTextScaling(base.worldTransform, pixelsPerPoint);
                    MeshGenerationContextUtils.TextParams textParams = MeshGenerationContextUtils.TextParams.MakeStyleBased(this, this.text);
                    textParams.text          = " ";
                    textParams.wordWrapWidth = 0f;
                    textParams.wordWrap      = false;
                    float num           = this.m_TextHandle.ComputeTextHeight(textParams, scaling);
                    float wordWrapWidth = 0f;
                    bool  flag2         = this.editorEngine.multiline && base.resolvedStyle.whiteSpace == WhiteSpace.Normal;
                    if (flag2)
                    {
                        wordWrapWidth = base.contentRect.width;
                    }
                    Vector2 p = this.editorEngine.graphicalCursorPos - scrollOffset;
                    p.y += num;
                    GUIUtility.compositionCursorPos = this.LocalToWorld(p);
                    Color cursorColor = this.cursorColor;
                    int   num2        = string.IsNullOrEmpty(GUIUtility.compositionString) ? selectIndex : (cursorIndex + GUIUtility.compositionString.Length);
                    bool  flag3       = cursorIndex != num2 && !this.isDragging;
                    if (flag3)
                    {
                        int cursorIndex2 = (cursorIndex < num2) ? cursorIndex : num2;
                        int cursorIndex3 = (cursorIndex > num2) ? cursorIndex : num2;
                        CursorPositionStylePainterParameters @default = CursorPositionStylePainterParameters.GetDefault(this, this.text);
                        @default.text          = this.editorEngine.text;
                        @default.wordWrapWidth = wordWrapWidth;
                        @default.cursorIndex   = cursorIndex2;
                        Vector2 vector = this.m_TextHandle.GetCursorPosition(@default, scaling);
                        @default.cursorIndex = cursorIndex3;
                        Vector2 vector2 = this.m_TextHandle.GetCursorPosition(@default, scaling);
                        vector  -= scrollOffset;
                        vector2 -= scrollOffset;
                        bool flag4 = Mathf.Approximately(vector.y, vector2.y);
                        if (flag4)
                        {
                            mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams
                            {
                                rect              = new Rect(vector.x, vector.y, vector2.x - vector.x, num),
                                color             = this.selectionColor,
                                playmodeTintColor = playmodeTintColor
                            });
                        }
                        else
                        {
                            mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams
                            {
                                rect              = new Rect(vector.x, vector.y, base.contentRect.xMax - vector.x, num),
                                color             = this.selectionColor,
                                playmodeTintColor = playmodeTintColor
                            });
                            float num3  = vector2.y - vector.y - num;
                            bool  flag5 = num3 > 0f;
                            if (flag5)
                            {
                                mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams
                                {
                                    rect              = new Rect(base.contentRect.xMin, vector.y + num, base.contentRect.width, num3),
                                    color             = this.selectionColor,
                                    playmodeTintColor = playmodeTintColor
                                });
                            }
                            bool flag6 = vector2.x != base.contentRect.x;
                            if (flag6)
                            {
                                mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams
                                {
                                    rect              = new Rect(base.contentRect.xMin, vector2.y, vector2.x, num),
                                    color             = this.selectionColor,
                                    playmodeTintColor = playmodeTintColor
                                });
                            }
                        }
                    }
                    bool flag7 = !string.IsNullOrEmpty(this.editorEngine.text) && base.contentRect.width > 0f && base.contentRect.height > 0f;
                    if (flag7)
                    {
                        textParams      = MeshGenerationContextUtils.TextParams.MakeStyleBased(this, this.text);
                        textParams.rect = new Rect(base.contentRect.x - scrollOffset.x, base.contentRect.y - scrollOffset.y, base.contentRect.width + scrollOffset.x, base.contentRect.height + scrollOffset.y);
                        textParams.text = this.editorEngine.text;
                        mgc.Text(textParams, this.m_TextHandle, base.scaledPixelsPerPoint);
                    }
                    bool flag8 = !this.isReadOnly && !this.isDragging;
                    if (flag8)
                    {
                        bool flag9 = cursorIndex == num2 && base.computedStyle.unityFont.value != null;
                        if (flag9)
                        {
                            CursorPositionStylePainterParameters @default = CursorPositionStylePainterParameters.GetDefault(this, this.text);
                            @default.text          = this.editorEngine.text;
                            @default.wordWrapWidth = wordWrapWidth;
                            @default.cursorIndex   = cursorIndex;
                            Vector2 vector3 = this.m_TextHandle.GetCursorPosition(@default, scaling);
                            vector3 -= scrollOffset;
                            mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams
                            {
                                rect              = new Rect(vector3.x, vector3.y, 1f, num),
                                color             = cursorColor,
                                playmodeTintColor = playmodeTintColor
                            });
                        }
                        bool flag10 = this.editorEngine.altCursorPosition != -1;
                        if (flag10)
                        {
                            CursorPositionStylePainterParameters @default = CursorPositionStylePainterParameters.GetDefault(this, this.text);
                            @default.text          = this.editorEngine.text.Substring(0, this.editorEngine.altCursorPosition);
                            @default.wordWrapWidth = wordWrapWidth;
                            @default.cursorIndex   = this.editorEngine.altCursorPosition;
                            Vector2 vector4 = this.m_TextHandle.GetCursorPosition(@default, scaling);
                            vector4 -= scrollOffset;
                            mgc.Rectangle(new MeshGenerationContextUtils.RectangleParams
                            {
                                rect              = new Rect(vector4.x, vector4.y, 1f, num),
                                color             = cursorColor,
                                playmodeTintColor = playmodeTintColor
                            });
                        }
                    }
                    keyboardTextEditorEventHandler.PostDrawCursor();
                }
            }
Пример #16
0
 public static void Text(this MeshGenerationContext mgc, TextParams textParams, TextHandle handle)
 {
     if (textParams.font != null)
     {
         mgc.painter.DrawText(textParams, handle);
     }
 }