Inheritance: PropertyDrawer
Ejemplo n.º 1
0
 private static void SetVerticalAlignment(SerializedProperty alignment, FontDataDrawer.VerticalTextAligment verticalAlignment)
 {
     foreach (Object targetObject in alignment.serializedObject.targetObjects)
     {
         Text text = targetObject as Text;
         FontDataDrawer.HorizontalTextAligment horizontalAlignment = FontDataDrawer.GetHorizontalAlignment(text.alignment);
         Undo.RecordObject((Object)text, "Vertical Alignment");
         text.alignment = FontDataDrawer.GetAnchor(verticalAlignment, horizontalAlignment);
         EditorUtility.SetDirty(targetObject);
     }
 }
Ejemplo n.º 2
0
 private static void SetVerticalAlignment(SerializedProperty alignment, FontDataDrawer.VerticalTextAligment verticalAlignment)
 {
     UnityEngine.Object[] targetObjects = alignment.serializedObject.targetObjects;
     for (int i = 0; i < targetObjects.Length; i++)
     {
         UnityEngine.Object @object = targetObjects[i];
         Text text = @object as Text;
         FontDataDrawer.HorizontalTextAligment horizontalAlignment = FontDataDrawer.GetHorizontalAlignment(text.alignment);
         Undo.RecordObject(text, "Vertical Alignment");
         text.alignment = FontDataDrawer.GetAnchor(verticalAlignment, horizontalAlignment);
         EditorUtility.SetDirty(@object);
     }
 }
Ejemplo n.º 3
0
        private static void DoVerticalAligmentControl(Rect position, SerializedProperty alignment)
        {
            TextAnchor intValue = (TextAnchor)alignment.intValue;

            FontDataDrawer.VerticalTextAligment verticalAlignment = FontDataDrawer.GetVerticalAlignment(intValue);
            bool flag  = verticalAlignment == FontDataDrawer.VerticalTextAligment.Top;
            bool flag2 = verticalAlignment == FontDataDrawer.VerticalTextAligment.Middle;
            bool flag3 = verticalAlignment == FontDataDrawer.VerticalTextAligment.Bottom;

            if (alignment.hasMultipleDifferentValues)
            {
                UnityEngine.Object[] targetObjects = alignment.serializedObject.targetObjects;
                for (int i = 0; i < targetObjects.Length; i++)
                {
                    UnityEngine.Object @object = targetObjects[i];
                    Text       text            = @object as Text;
                    TextAnchor alignment2      = text.alignment;
                    verticalAlignment = FontDataDrawer.GetVerticalAlignment(alignment2);
                    flag  = (flag || verticalAlignment == FontDataDrawer.VerticalTextAligment.Top);
                    flag2 = (flag2 || verticalAlignment == FontDataDrawer.VerticalTextAligment.Middle);
                    flag3 = (flag3 || verticalAlignment == FontDataDrawer.VerticalTextAligment.Bottom);
                }
            }
            position.width = 20f;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag, (!flag) ? FontDataDrawer.Styles.m_TopAlignText : FontDataDrawer.Styles.m_TopAlignTextActive, FontDataDrawer.Styles.alignmentButtonLeft);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetVerticalAlignment(alignment, FontDataDrawer.VerticalTextAligment.Top);
            }
            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag2, (!flag2) ? FontDataDrawer.Styles.m_MiddleAlignText : FontDataDrawer.Styles.m_MiddleAlignTextActive, FontDataDrawer.Styles.alignmentButtonMid);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetVerticalAlignment(alignment, FontDataDrawer.VerticalTextAligment.Middle);
            }
            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag3, (!flag3) ? FontDataDrawer.Styles.m_BottomAlignText : FontDataDrawer.Styles.m_BottomAlignTextActive, FontDataDrawer.Styles.alignmentButtonRight);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetVerticalAlignment(alignment, FontDataDrawer.VerticalTextAligment.Bottom);
            }
        }
Ejemplo n.º 4
0
        private void DoTextAligmentControl(Rect position, SerializedProperty alignment)
        {
            GUIContent label     = new GUIContent("Alignment");
            int        controlID = GUIUtility.GetControlID(FontDataDrawer.s_TextAlignmentHash, FocusType.Keyboard, position);

            EditorGUIUtility.SetIconSize(new Vector2(15f, 15f));
            EditorGUI.BeginProperty(position, label, alignment);
            Rect  rect      = EditorGUI.PrefixLabel(position, controlID, label);
            float num       = 60f;
            float num2      = Mathf.Clamp(rect.width - num * 2f, 2f, 10f);
            Rect  position2 = new Rect(rect.x, rect.y, num, rect.height);
            Rect  position3 = new Rect(position2.xMax + num2, rect.y, num, rect.height);

            FontDataDrawer.DoHorizontalAligmentControl(position2, alignment);
            FontDataDrawer.DoVerticalAligmentControl(position3, alignment);
            EditorGUI.EndProperty();
            EditorGUIUtility.SetIconSize(Vector2.zero);
        }
Ejemplo n.º 5
0
        private static void DoHorizontalAligmentControl(Rect position, SerializedProperty alignment)
        {
            TextAnchor intValue = (TextAnchor)alignment.intValue;

            FontDataDrawer.HorizontalTextAligment horizontalAlignment = FontDataDrawer.GetHorizontalAlignment(intValue);
            bool flag  = horizontalAlignment == FontDataDrawer.HorizontalTextAligment.Left;
            bool flag2 = horizontalAlignment == FontDataDrawer.HorizontalTextAligment.Center;
            bool flag3 = horizontalAlignment == FontDataDrawer.HorizontalTextAligment.Right;

            if (alignment.hasMultipleDifferentValues)
            {
                UnityEngine.Object[] targetObjects = alignment.serializedObject.targetObjects;
                for (int i = 0; i < targetObjects.Length; i++)
                {
                    UnityEngine.Object @object = targetObjects[i];
                    Text text = @object as Text;
                    horizontalAlignment = FontDataDrawer.GetHorizontalAlignment(text.alignment);
                    flag  = (flag || horizontalAlignment == FontDataDrawer.HorizontalTextAligment.Left);
                    flag2 = (flag2 || horizontalAlignment == FontDataDrawer.HorizontalTextAligment.Center);
                    flag3 = (flag3 || horizontalAlignment == FontDataDrawer.HorizontalTextAligment.Right);
                }
            }
            position.width = 20f;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag, (!flag) ? FontDataDrawer.Styles.m_LeftAlignText : FontDataDrawer.Styles.m_LeftAlignTextActive, FontDataDrawer.Styles.alignmentButtonLeft);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetHorizontalAlignment(alignment, FontDataDrawer.HorizontalTextAligment.Left);
            }
            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag2, (!flag2) ? FontDataDrawer.Styles.m_CenterAlignText : FontDataDrawer.Styles.m_CenterAlignTextActive, FontDataDrawer.Styles.alignmentButtonMid);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetHorizontalAlignment(alignment, FontDataDrawer.HorizontalTextAligment.Center);
            }
            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag3, (!flag3) ? FontDataDrawer.Styles.m_RightAlignText : FontDataDrawer.Styles.m_RightAlignTextActive, FontDataDrawer.Styles.alignmentButtonRight);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetHorizontalAlignment(alignment, FontDataDrawer.HorizontalTextAligment.Right);
            }
        }
Ejemplo n.º 6
0
        private static void DoVerticalAligmentControl(Rect position, SerializedProperty alignment)
        {
            FontDataDrawer.VerticalTextAligment verticalAlignment1 = FontDataDrawer.GetVerticalAlignment((TextAnchor)alignment.intValue);
            bool flag1 = verticalAlignment1 == FontDataDrawer.VerticalTextAligment.Top;
            bool flag2 = verticalAlignment1 == FontDataDrawer.VerticalTextAligment.Middle;
            bool flag3 = verticalAlignment1 == FontDataDrawer.VerticalTextAligment.Bottom;

            if (alignment.hasMultipleDifferentValues)
            {
                foreach (Object targetObject in alignment.serializedObject.targetObjects)
                {
                    FontDataDrawer.VerticalTextAligment verticalAlignment2 = FontDataDrawer.GetVerticalAlignment((targetObject as Text).alignment);
                    flag1 = flag1 || verticalAlignment2 == FontDataDrawer.VerticalTextAligment.Top;
                    flag2 = flag2 || verticalAlignment2 == FontDataDrawer.VerticalTextAligment.Middle;
                    flag3 = flag3 || verticalAlignment2 == FontDataDrawer.VerticalTextAligment.Bottom;
                }
            }
            position.width = 20f;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag1, !flag1 ? FontDataDrawer.Styles.m_TopAlignText : FontDataDrawer.Styles.m_TopAlignTextActive, FontDataDrawer.Styles.alignmentButtonLeft);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetVerticalAlignment(alignment, FontDataDrawer.VerticalTextAligment.Top);
            }
            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag2, !flag2 ? FontDataDrawer.Styles.m_MiddleAlignText : FontDataDrawer.Styles.m_MiddleAlignTextActive, FontDataDrawer.Styles.alignmentButtonMid);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetVerticalAlignment(alignment, FontDataDrawer.VerticalTextAligment.Middle);
            }
            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag3, !flag3 ? FontDataDrawer.Styles.m_BottomAlignText : FontDataDrawer.Styles.m_BottomAlignTextActive, FontDataDrawer.Styles.alignmentButtonRight);
            if (!EditorGUI.EndChangeCheck())
            {
                return;
            }
            FontDataDrawer.SetVerticalAlignment(alignment, FontDataDrawer.VerticalTextAligment.Bottom);
        }
Ejemplo n.º 7
0
        private static void DoHorizontalAligmentControl(Rect position, SerializedProperty alignment)
        {
            FontDataDrawer.HorizontalTextAligment horizontalAlignment1 = FontDataDrawer.GetHorizontalAlignment((TextAnchor)alignment.intValue);
            bool flag1 = horizontalAlignment1 == FontDataDrawer.HorizontalTextAligment.Left;
            bool flag2 = horizontalAlignment1 == FontDataDrawer.HorizontalTextAligment.Center;
            bool flag3 = horizontalAlignment1 == FontDataDrawer.HorizontalTextAligment.Right;

            if (alignment.hasMultipleDifferentValues)
            {
                foreach (Object targetObject in alignment.serializedObject.targetObjects)
                {
                    FontDataDrawer.HorizontalTextAligment horizontalAlignment2 = FontDataDrawer.GetHorizontalAlignment((targetObject as Text).alignment);
                    flag1 = flag1 || horizontalAlignment2 == FontDataDrawer.HorizontalTextAligment.Left;
                    flag2 = flag2 || horizontalAlignment2 == FontDataDrawer.HorizontalTextAligment.Center;
                    flag3 = flag3 || horizontalAlignment2 == FontDataDrawer.HorizontalTextAligment.Right;
                }
            }
            position.width = 20f;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag1, !flag1 ? FontDataDrawer.Styles.m_LeftAlignText : FontDataDrawer.Styles.m_LeftAlignTextActive, FontDataDrawer.Styles.alignmentButtonLeft);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetHorizontalAlignment(alignment, FontDataDrawer.HorizontalTextAligment.Left);
            }
            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag2, !flag2 ? FontDataDrawer.Styles.m_CenterAlignText : FontDataDrawer.Styles.m_CenterAlignTextActive, FontDataDrawer.Styles.alignmentButtonMid);
            if (EditorGUI.EndChangeCheck())
            {
                FontDataDrawer.SetHorizontalAlignment(alignment, FontDataDrawer.HorizontalTextAligment.Center);
            }
            position.x += position.width;
            EditorGUI.BeginChangeCheck();
            FontDataDrawer.EditorToggle(position, flag3, !flag3 ? FontDataDrawer.Styles.m_RightAlignText : FontDataDrawer.Styles.m_RightAlignTextActive, FontDataDrawer.Styles.alignmentButtonRight);
            if (!EditorGUI.EndChangeCheck())
            {
                return;
            }
            FontDataDrawer.SetHorizontalAlignment(alignment, FontDataDrawer.HorizontalTextAligment.Right);
        }
Ejemplo n.º 8
0
 private static TextAnchor GetAnchor(FontDataDrawer.VerticalTextAligment verticalTextAligment, FontDataDrawer.HorizontalTextAligment horizontalTextAligment)
 {
   switch (horizontalTextAligment)
   {
     case FontDataDrawer.HorizontalTextAligment.Left:
       switch (verticalTextAligment)
       {
         case FontDataDrawer.VerticalTextAligment.Middle:
           return TextAnchor.MiddleLeft;
         case FontDataDrawer.VerticalTextAligment.Bottom:
           return TextAnchor.LowerLeft;
         default:
           return TextAnchor.UpperLeft;
       }
     case FontDataDrawer.HorizontalTextAligment.Center:
       switch (verticalTextAligment)
       {
         case FontDataDrawer.VerticalTextAligment.Middle:
           return TextAnchor.MiddleCenter;
         case FontDataDrawer.VerticalTextAligment.Bottom:
           return TextAnchor.LowerCenter;
         default:
           return TextAnchor.UpperCenter;
       }
     default:
       switch (verticalTextAligment)
       {
         case FontDataDrawer.VerticalTextAligment.Middle:
           return TextAnchor.MiddleRight;
         case FontDataDrawer.VerticalTextAligment.Bottom:
           return TextAnchor.LowerRight;
         default:
           return TextAnchor.UpperRight;
       }
   }
 }
Ejemplo n.º 9
0
 private static void SetVerticalAlignment(SerializedProperty alignment, FontDataDrawer.VerticalTextAligment verticalAlignment)
 {
   foreach (Object targetObject in alignment.serializedObject.targetObjects)
   {
     Text text = targetObject as Text;
     FontDataDrawer.HorizontalTextAligment horizontalAlignment = FontDataDrawer.GetHorizontalAlignment(text.alignment);
     Undo.RecordObject((Object) text, "Vertical Alignment");
     text.alignment = FontDataDrawer.GetAnchor(verticalAlignment, horizontalAlignment);
     EditorUtility.SetDirty(targetObject);
   }
 }