GetHorizontalAlignment() private static method

private static GetHorizontalAlignment ( TextAnchor ta ) : HorizontalTextAligment
ta TextAnchor
return HorizontalTextAligment
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 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.º 4
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);
        }