예제 #1
0
        public static void TrackText(TextEx t)
        {
            if (t.font == null)
            {
                return;
            }

            List <TextEx> exists;

            m_Tracked.TryGetValue(t.font, out exists);
            if (exists == null)
            {
                exists = new List <TextEx>();
                m_Tracked.Add(t.font, exists);

                Font.textureRebuilt += RebuildForFont;
            }

            for (int i = 0; i < exists.Count; i++)
            {
                if (exists[i] == t)
                {
                    return;
                }
            }

            exists.Add(t);
        }
예제 #2
0
 private static void SetVerticalAlignment(SerializedProperty alignment, VerticalTextAligment verticalAlignment)
 {
     foreach (var obj in alignment.serializedObject.targetObjects)
     {
         TextEx text = obj as TextEx;
         HorizontalTextAligment currentHorizontalAligment = GetHorizontalAlignment(text.alignment);
         Undo.RecordObject(text, "Vertical Alignment");
         text.alignment = GetAnchor(verticalAlignment, currentHorizontalAligment);
         EditorUtility.SetDirty(obj);
     }
 }
예제 #3
0
        private static void DoVerticalAligmentControl(Rect position, SerializedProperty alignment)
        {
            TextAnchor           ta = (TextAnchor)alignment.intValue;
            VerticalTextAligment verticalTextAligment = GetVerticalAlignment(ta);

            bool topAlign    = (verticalTextAligment == VerticalTextAligment.Top);
            bool middleAlign = (verticalTextAligment == VerticalTextAligment.Middle);
            bool bottomAlign = (verticalTextAligment == VerticalTextAligment.Bottom);

            if (alignment.hasMultipleDifferentValues)
            {
                foreach (var obj in alignment.serializedObject.targetObjects)
                {
                    TextEx     text          = obj as TextEx;
                    TextAnchor textAlignment = text.alignment;
                    verticalTextAligment = GetVerticalAlignment(textAlignment);
                    topAlign             = topAlign || (verticalTextAligment == VerticalTextAligment.Top);
                    middleAlign          = middleAlign || (verticalTextAligment == VerticalTextAligment.Middle);
                    bottomAlign          = bottomAlign || (verticalTextAligment == VerticalTextAligment.Bottom);
                }
            }


            position.width = kAlignmentButtonWidth;

            // position.x += position.width;
            EditorGUI.BeginChangeCheck();
            EditorToggle(position, topAlign, topAlign ? Styles.m_TopAlignTextActive : Styles.m_TopAlignText,
                         Styles.alignmentButtonLeft);
            if (EditorGUI.EndChangeCheck())
            {
                SetVerticalAlignment(alignment, VerticalTextAligment.Top);
            }

            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            EditorToggle(position, middleAlign, middleAlign ? Styles.m_MiddleAlignTextActive : Styles.m_MiddleAlignText,
                         Styles.alignmentButtonMid);
            if (EditorGUI.EndChangeCheck())
            {
                SetVerticalAlignment(alignment, VerticalTextAligment.Middle);
            }

            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            EditorToggle(position, bottomAlign, bottomAlign ? Styles.m_BottomAlignTextActive : Styles.m_BottomAlignText,
                         Styles.alignmentButtonRight);
            if (EditorGUI.EndChangeCheck())
            {
                SetVerticalAlignment(alignment, VerticalTextAligment.Bottom);
            }
        }
예제 #4
0
        private static void DoHorizontalAligmentControl(Rect position, SerializedProperty alignment)
        {
            TextAnchor             ta = (TextAnchor)alignment.intValue;
            HorizontalTextAligment horizontalAlignment = GetHorizontalAlignment(ta);

            bool leftAlign   = (horizontalAlignment == HorizontalTextAligment.Left);
            bool centerAlign = (horizontalAlignment == HorizontalTextAligment.Center);
            bool rightAlign  = (horizontalAlignment == HorizontalTextAligment.Right);

            if (alignment.hasMultipleDifferentValues)
            {
                foreach (var obj in alignment.serializedObject.targetObjects)
                {
                    TextEx text = obj as TextEx;
                    horizontalAlignment = GetHorizontalAlignment(text.alignment);
                    leftAlign           = leftAlign || (horizontalAlignment == HorizontalTextAligment.Left);
                    centerAlign         = centerAlign || (horizontalAlignment == HorizontalTextAligment.Center);
                    rightAlign          = rightAlign || (horizontalAlignment == HorizontalTextAligment.Right);
                }
            }

            position.width = kAlignmentButtonWidth;

            EditorGUI.BeginChangeCheck();
            EditorToggle(position, leftAlign, leftAlign ? Styles.m_LeftAlignTextActive : Styles.m_LeftAlignText,
                         Styles.alignmentButtonLeft);
            if (EditorGUI.EndChangeCheck())
            {
                SetHorizontalAlignment(alignment, HorizontalTextAligment.Left);
            }

            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            EditorToggle(position, centerAlign, centerAlign ? Styles.m_CenterAlignTextActive : Styles.m_CenterAlignText,
                         Styles.alignmentButtonMid);
            if (EditorGUI.EndChangeCheck())
            {
                SetHorizontalAlignment(alignment, HorizontalTextAligment.Center);
            }

            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            EditorToggle(position, rightAlign, rightAlign ? Styles.m_RightAlignTextActive : Styles.m_RightAlignText,
                         Styles.alignmentButtonRight);
            if (EditorGUI.EndChangeCheck())
            {
                SetHorizontalAlignment(alignment, HorizontalTextAligment.Right);
            }
        }
예제 #5
0
        public static void UntrackText(TextEx t)
        {
            if (t.font == null)
            {
                return;
            }

            List <TextEx> texts;

            m_Tracked.TryGetValue(t.font, out texts);

            if (texts == null)
            {
                return;
            }

            texts.Remove(t);
        }