private static TextAnchor GetAnchor(FontDataDrawer.VerticalTextAligment verticalTextAligment, FontDataDrawer.HorizontalTextAligment horizontalTextAligment) { TextAnchor result; if (horizontalTextAligment != FontDataDrawer.HorizontalTextAligment.Left) { if (horizontalTextAligment != FontDataDrawer.HorizontalTextAligment.Center) { if (verticalTextAligment != FontDataDrawer.VerticalTextAligment.Bottom) { if (verticalTextAligment != FontDataDrawer.VerticalTextAligment.Middle) { result = TextAnchor.UpperRight; } else { result = TextAnchor.MiddleRight; } } else { result = TextAnchor.LowerRight; } } else if (verticalTextAligment != FontDataDrawer.VerticalTextAligment.Bottom) { if (verticalTextAligment != FontDataDrawer.VerticalTextAligment.Middle) { result = TextAnchor.UpperCenter; } else { result = TextAnchor.MiddleCenter; } } else { result = TextAnchor.LowerCenter; } } else if (verticalTextAligment != FontDataDrawer.VerticalTextAligment.Bottom) { if (verticalTextAligment != FontDataDrawer.VerticalTextAligment.Middle) { result = TextAnchor.UpperLeft; } else { result = TextAnchor.MiddleLeft; } } else { result = TextAnchor.LowerLeft; } return(result); }
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); } }
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); } }
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); } }
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); } } }
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); }