UnityEngine.GUIStyle.DrawWithTextSelection C# (CSharp) Method

DrawWithTextSelection() private method

private DrawWithTextSelection ( Rect position, GUIContent content, int controlID, int firstSelectedCharacter, int lastSelectedCharacter, bool drawSelectionAsComposition ) : void
position Rect
content GUIContent
controlID int
firstSelectedCharacter int
lastSelectedCharacter int
drawSelectionAsComposition bool
return void
        internal void DrawWithTextSelection(Rect position, GUIContent content, int controlID, int firstSelectedCharacter, int lastSelectedCharacter, bool drawSelectionAsComposition)
        {
            if (Event.current.type != EventType.Repaint)
            {
                Debug.LogError("Style.Draw may not be called if it is not a repaint event");
            }
            else
            {
                Event current = Event.current;
                Color cursorColor = new Color(0f, 0f, 0f, 0f);
                float cursorFlashSpeed = GUI.skin.settings.cursorFlashSpeed;
                float num2 = ((Time.realtimeSinceStartup - Internal_GetCursorFlashOffset()) % cursorFlashSpeed) / cursorFlashSpeed;
                if ((cursorFlashSpeed == 0f) || (num2 < 0.5f))
                {
                    cursorColor = GUI.skin.settings.cursorColor;
                }
                Internal_DrawWithTextSelectionArguments arguments = new Internal_DrawWithTextSelectionArguments {
                    target = this.m_Ptr,
                    position = position,
                    firstPos = firstSelectedCharacter,
                    lastPos = lastSelectedCharacter,
                    cursorColor = cursorColor,
                    selectionColor = GUI.skin.settings.selectionColor,
                    isHover = !position.Contains(current.mousePosition) ? 0 : 1,
                    isActive = (controlID != GUIUtility.hotControl) ? 0 : 1,
                    on = 0,
                    hasKeyboardFocus = ((controlID != GUIUtility.keyboardControl) || !showKeyboardFocus) ? 0 : 1,
                    drawSelectionAsComposition = !drawSelectionAsComposition ? 0 : 1
                };
                Internal_DrawWithTextSelection(content, ref arguments);
            }
        }

Same methods

GUIStyle::DrawWithTextSelection ( Rect position, GUIContent content, int controlID, int firstSelectedCharacter, int lastSelectedCharacter ) : void

Usage Example

コード例 #1
0
        public void DrawCursor(string newText)
        {
            string text = this.text;
            int    num  = cursorIndex;

            if (Input.compositionString.Length > 0)
            {
                m_Content.text = newText.Substring(0, cursorIndex) + Input.compositionString + newText.Substring(selectIndex);
                num           += Input.compositionString.Length;
            }
            else
            {
                m_Content.text = newText;
            }

            graphicalCursorPos = style.GetCursorPixelPosition(new Rect(0f, 0f, position.width, position.height), m_Content, num);
            Vector2 contentOffset = style.contentOffset;

            style.contentOffset       -= scrollOffset;
            style.Internal_clipOffset  = scrollOffset;
            Input.compositionCursorPos = graphicalCursorPos + new Vector2(position.x, position.y + style.lineHeight) - scrollOffset;
            if (Input.compositionString.Length > 0)
            {
                style.DrawWithTextSelection(position, m_Content, controlID, cursorIndex, cursorIndex + Input.compositionString.Length, drawSelectionAsComposition: true);
            }
            else
            {
                style.DrawWithTextSelection(position, m_Content, controlID, cursorIndex, selectIndex);
            }

            if (m_iAltCursorPos != -1)
            {
                style.DrawCursor(position, m_Content, controlID, m_iAltCursorPos);
            }

            style.contentOffset       = contentOffset;
            style.Internal_clipOffset = Vector2.zero;
            m_Content.text            = text;
        }
All Usage Examples Of UnityEngine.GUIStyle::DrawWithTextSelection