Skip to content

Commit

Permalink
Commit of 2019.1 at 0ca0f5646614 (2019.1.5f1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Cosgrave committed Jun 5, 2019
1 parent 1133bca commit 3bc6a8f
Show file tree
Hide file tree
Showing 53 changed files with 1,239 additions and 453 deletions.
3 changes: 3 additions & 0 deletions UnityEditor.UI/UI/DropdownEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class DropdownEditor : SelectableEditor
SerializedProperty m_OnSelectionChanged;
SerializedProperty m_Value;
SerializedProperty m_Options;
SerializedProperty m_AlphaFadeSpeed;

protected override void OnEnable()
{
Expand All @@ -30,6 +31,7 @@ protected override void OnEnable()
m_OnSelectionChanged = serializedObject.FindProperty("m_OnValueChanged");
m_Value = serializedObject.FindProperty("m_Value");
m_Options = serializedObject.FindProperty("m_Options");
m_AlphaFadeSpeed = serializedObject.FindProperty("m_AlphaFadeSpeed");
}

public override void OnInspectorGUI()
Expand All @@ -44,6 +46,7 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(m_ItemText);
EditorGUILayout.PropertyField(m_ItemImage);
EditorGUILayout.PropertyField(m_Value);
EditorGUILayout.PropertyField(m_AlphaFadeSpeed);
EditorGUILayout.PropertyField(m_Options);
EditorGUILayout.PropertyField(m_OnSelectionChanged);
serializedObject.ApplyModifiedProperties();
Expand Down
15 changes: 14 additions & 1 deletion UnityEditor.UI/UI/HorizontalOrVerticalLayoutGroupEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class HorizontalOrVerticalLayoutGroupEditor : Editor
SerializedProperty m_ChildAlignment;
SerializedProperty m_ChildControlWidth;
SerializedProperty m_ChildControlHeight;
SerializedProperty m_ChildScaleWidth;
SerializedProperty m_ChildScaleHeight;
SerializedProperty m_ChildForceExpandWidth;
SerializedProperty m_ChildForceExpandHeight;

Expand All @@ -28,6 +30,8 @@ protected virtual void OnEnable()
m_ChildAlignment = serializedObject.FindProperty("m_ChildAlignment");
m_ChildControlWidth = serializedObject.FindProperty("m_ChildControlWidth");
m_ChildControlHeight = serializedObject.FindProperty("m_ChildControlHeight");
m_ChildScaleWidth = serializedObject.FindProperty("m_ChildScaleWidth");
m_ChildScaleHeight = serializedObject.FindProperty("m_ChildScaleHeight");
m_ChildForceExpandWidth = serializedObject.FindProperty("m_ChildForceExpandWidth");
m_ChildForceExpandHeight = serializedObject.FindProperty("m_ChildForceExpandHeight");
}
Expand All @@ -40,14 +44,23 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(m_ChildAlignment, true);

Rect rect = EditorGUILayout.GetControlRect();
rect = EditorGUI.PrefixLabel(rect, -1, EditorGUIUtility.TrTextContent("Child Controls Size"));
rect = EditorGUI.PrefixLabel(rect, -1, EditorGUIUtility.TrTextContent("Control Child Size"));
rect.width = Mathf.Max(50, (rect.width - 4) / 3);
EditorGUIUtility.labelWidth = 50;
ToggleLeft(rect, m_ChildControlWidth, EditorGUIUtility.TrTextContent("Width"));
rect.x += rect.width + 2;
ToggleLeft(rect, m_ChildControlHeight, EditorGUIUtility.TrTextContent("Height"));
EditorGUIUtility.labelWidth = 0;

rect = EditorGUILayout.GetControlRect();
rect = EditorGUI.PrefixLabel(rect, -1, EditorGUIUtility.TrTextContent("Use Child Scale"));
rect.width = Mathf.Max(50, (rect.width - 4) / 3);
EditorGUIUtility.labelWidth = 50;
ToggleLeft(rect, m_ChildScaleWidth, EditorGUIUtility.TrTextContent("Width"));
rect.x += rect.width + 2;
ToggleLeft(rect, m_ChildScaleHeight, EditorGUIUtility.TrTextContent("Height"));
EditorGUIUtility.labelWidth = 0;

rect = EditorGUILayout.GetControlRect();
rect = EditorGUI.PrefixLabel(rect, -1, EditorGUIUtility.TrTextContent("Child Force Expand"));
rect.width = Mathf.Max(50, (rect.width - 4) / 3);
Expand Down
1 change: 1 addition & 0 deletions UnityEditor.UI/UI/ImageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ protected void SpriteGUI()
m_Type.enumValueIndex = (int)Image.Type.Simple;
}
}
(serializedObject.targetObject as Image).DisableSpriteOptimizations();
}
}

Expand Down
13 changes: 7 additions & 6 deletions UnityEditor.UI/UI/LayoutPropertiesPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using System.Globalization;

namespace UnityEditor.Events
{
Expand Down Expand Up @@ -94,17 +95,17 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)

// Show properties

ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Width", LayoutUtility.GetLayoutProperty(rect, e => e.minWidth, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Height", LayoutUtility.GetLayoutProperty(rect, e => e.minHeight, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Width", LayoutUtility.GetLayoutProperty(rect, e => e.preferredWidth, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Height", LayoutUtility.GetLayoutProperty(rect, e => e.preferredHeight, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Width", LayoutUtility.GetLayoutProperty(rect, e => e.minWidth, 0, out source).ToString(CultureInfo.InvariantCulture.NumberFormat), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Height", LayoutUtility.GetLayoutProperty(rect, e => e.minHeight, 0, out source).ToString(CultureInfo.InvariantCulture.NumberFormat), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Width", LayoutUtility.GetLayoutProperty(rect, e => e.preferredWidth, 0, out source).ToString(CultureInfo.InvariantCulture.NumberFormat), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Height", LayoutUtility.GetLayoutProperty(rect, e => e.preferredHeight, 0, out source).ToString(CultureInfo.InvariantCulture.NumberFormat), source);

float flexible = 0;

flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleWidth, 0, out source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Width", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Width", flexible > 0 ? ("enabled (" + flexible.ToString(CultureInfo.InvariantCulture.NumberFormat) + ")") : "disabled", source);
flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleHeight, 0, out source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Height", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Height", flexible > 0 ? ("enabled (" + flexible.ToString(CultureInfo.InvariantCulture.NumberFormat) + ")") : "disabled", source);

if (!rect.GetComponent<LayoutElement>())
{
Expand Down
2 changes: 1 addition & 1 deletion UnityEditor.UI/UI/MenuOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private static void PlaceUIElementRoot(GameObject element, MenuCommand menuComma
if (prefabStage != null && !prefabStage.IsPartOfPrefabContents(parent))
parent = prefabStage.prefabContentsRoot;
}
if (parent.GetComponentInParent<Canvas>() == null)
if (parent.GetComponentsInParent<Canvas>(true).Length == 0)
{
// Create canvas under context GameObject,
// and make that be the parent which UI element is added under.
Expand Down
5 changes: 4 additions & 1 deletion UnityEditor.UI/UI/PropertyDrawers/AnimationTriggersDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
SerializedProperty normalTrigger = prop.FindPropertyRelative("m_NormalTrigger");
SerializedProperty higlightedTrigger = prop.FindPropertyRelative("m_HighlightedTrigger");
SerializedProperty pressedTrigger = prop.FindPropertyRelative("m_PressedTrigger");
SerializedProperty selectedTrigger = prop.FindPropertyRelative("m_SelectedTrigger");
SerializedProperty disabledTrigger = prop.FindPropertyRelative("m_DisabledTrigger");

EditorGUI.PropertyField(drawRect, normalTrigger);
Expand All @@ -25,12 +26,14 @@ public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, pressedTrigger);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectedTrigger);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, disabledTrigger);
}

public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
5 changes: 4 additions & 1 deletion UnityEditor.UI/UI/PropertyDrawers/ColorBlockDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
SerializedProperty normalColor = prop.FindPropertyRelative("m_NormalColor");
SerializedProperty highlighted = prop.FindPropertyRelative("m_HighlightedColor");
SerializedProperty pressedColor = prop.FindPropertyRelative("m_PressedColor");
SerializedProperty selectedColor = prop.FindPropertyRelative("m_SelectedColor");
SerializedProperty disabledColor = prop.FindPropertyRelative("m_DisabledColor");
SerializedProperty colorMultiplier = prop.FindPropertyRelative("m_ColorMultiplier");
SerializedProperty fadeDuration = prop.FindPropertyRelative("m_FadeDuration");
Expand All @@ -27,6 +28,8 @@ public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, pressedColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectedColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, disabledColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, colorMultiplier);
Expand All @@ -36,7 +39,7 @@ public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)

public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
return 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
5 changes: 4 additions & 1 deletion UnityEditor.UI/UI/PropertyDrawers/SpriteStateDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty highlightedSprite = prop.FindPropertyRelative("m_HighlightedSprite");
SerializedProperty pressedSprite = prop.FindPropertyRelative("m_PressedSprite");
SerializedProperty selectedSprite = prop.FindPropertyRelative("m_SelectedSprite");
SerializedProperty disabledSprite = prop.FindPropertyRelative("m_DisabledSprite");

EditorGUI.PropertyField(drawRect, highlightedSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, pressedSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectedSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, disabledSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}

public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
return 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
1 change: 1 addition & 0 deletions UnityEditor.UI/UI/RawImageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public override void OnInspectorGUI()
serializedObject.Update();

EditorGUILayout.PropertyField(m_Texture);

AppearanceControlsGUI();
RaycastControlsGUI();
EditorGUILayout.PropertyField(m_UVRect, m_UVRectContent);
Expand Down
16 changes: 10 additions & 6 deletions UnityEditor.UI/UI/SelectableEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ protected virtual void OnDisable()

private void RegisterStaticOnSceneGUI()
{
SceneView.onSceneGUIDelegate -= StaticOnSceneGUI;
SceneView.duringSceneGui -= StaticOnSceneGUI;
if (s_Editors.Count > 0)
SceneView.onSceneGUIDelegate += StaticOnSceneGUI;
SceneView.duringSceneGui += StaticOnSceneGUI;
}

static Selectable.Transition GetTransition(SerializedProperty transition)
Expand Down Expand Up @@ -222,13 +222,15 @@ private static Animations.AnimatorController GenerateSelectableAnimatorContoller
var normalName = string.IsNullOrEmpty(animationTriggers.normalTrigger) ? "Normal" : animationTriggers.normalTrigger;
var highlightedName = string.IsNullOrEmpty(animationTriggers.highlightedTrigger) ? "Highlighted" : animationTriggers.highlightedTrigger;
var pressedName = string.IsNullOrEmpty(animationTriggers.pressedTrigger) ? "Pressed" : animationTriggers.pressedTrigger;
var selectedName = string.IsNullOrEmpty(animationTriggers.selectedTrigger) ? "Selected" : animationTriggers.selectedTrigger;
var disabledName = string.IsNullOrEmpty(animationTriggers.disabledTrigger) ? "Disabled" : animationTriggers.disabledTrigger;

// Create controller and hook up transitions.
var controller = Animations.AnimatorController.CreateAnimatorControllerAtPath(path);
GenerateTriggerableTransition(normalName, controller);
GenerateTriggerableTransition(highlightedName, controller);
GenerateTriggerableTransition(pressedName, controller);
GenerateTriggerableTransition(selectedName, controller);
GenerateTriggerableTransition(disabledName, controller);

AssetDatabase.ImportAsset(path);
Expand Down Expand Up @@ -315,11 +317,13 @@ private static void StaticOnSceneGUI(SceneView view)
if (!s_ShowNavigation)
return;

for (int i = 0; i < Selectable.allSelectables.Count; i++)
Selectable[] selectables = Selectable.allSelectablesArray;

for (int i = 0; i < selectables.Length; i++)
{
Selectable selectable = Selectable.allSelectables[i];
if (SceneManagement.StageUtility.IsGameObjectRenderedByCamera(selectable.gameObject, Camera.current))
DrawNavigationForSelectable(selectable);
Selectable s = selectables[i];
if (SceneManagement.StageUtility.IsGameObjectRenderedByCamera(s.gameObject, Camera.current))
DrawNavigationForSelectable(s);
}
}

Expand Down
1 change: 1 addition & 0 deletions UnityEditor.UI/UI/TextEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public override void OnInspectorGUI()

EditorGUILayout.PropertyField(m_Text);
EditorGUILayout.PropertyField(m_FontData);

AppearanceControlsGUI();
RaycastControlsGUI();
serializedObject.ApplyModifiedProperties();
Expand Down
24 changes: 24 additions & 0 deletions UnityEditor.UI/UI/ToggleEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,34 @@ public override void OnInspectorGUI()
EditorGUILayout.Space();

serializedObject.Update();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_IsOnProperty);
if (EditorGUI.EndChangeCheck())
{
Toggle toggle = serializedObject.targetObject as Toggle;
ToggleGroup group = m_GroupProperty.objectReferenceValue as ToggleGroup;

toggle.isOn = m_IsOnProperty.boolValue;

if (group != null && toggle.IsActive())
{
if (toggle.isOn || (!group.AnyTogglesOn() && !group.allowSwitchOff))
{
toggle.isOn = true;
group.NotifyToggleOn(toggle);
}
}
}
EditorGUILayout.PropertyField(m_TransitionProperty);
EditorGUILayout.PropertyField(m_GraphicProperty);
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_GroupProperty);
if (EditorGUI.EndChangeCheck())
{
Toggle toggle = serializedObject.targetObject as Toggle;
ToggleGroup group = m_GroupProperty.objectReferenceValue as ToggleGroup;
toggle.group = group;
}

EditorGUILayout.Space();

Expand Down
4 changes: 2 additions & 2 deletions UnityEngine.UI/EventSystem/EventData/PointerEventData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ public override string ToString()
sb.AppendLine("<b>lastPointerPress</b>: " + lastPress);
sb.AppendLine("<b>pointerDrag</b>: " + pointerDrag);
sb.AppendLine("<b>Use Drag Threshold</b>: " + useDragThreshold);
sb.AppendLine("<b>Current Rayast:</b>");
sb.AppendLine("<b>Current Raycast:</b>");
sb.AppendLine(pointerCurrentRaycast.ToString());
sb.AppendLine("<b>Press Rayast:</b>");
sb.AppendLine("<b>Press Raycast:</b>");
sb.AppendLine(pointerPressRaycast.ToString());
return sb.ToString();
}
Expand Down
4 changes: 2 additions & 2 deletions UnityEngine.UI/EventSystem/EventSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ private static int RaycastComparer(RaycastResult lhs, RaycastResult rhs)
return rid.CompareTo(lid);
}


if (lhs.sortingOrder != rhs.sortingOrder)
return rhs.sortingOrder.CompareTo(lhs.sortingOrder);

if (lhs.depth != rhs.depth)
// comparing depth only makes sense if the two raycast results have the same root canvas (case 912396)
if (lhs.depth != rhs.depth && lhs.module.rootRaycaster == rhs.module.rootRaycaster)
return rhs.depth.CompareTo(lhs.depth);

if (lhs.distance != rhs.distance)
Expand Down
2 changes: 1 addition & 1 deletion UnityEngine.UI/EventSystem/EventTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public class Entry

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[Obsolete("Please use triggers instead (UnityUpgradable) -> triggers", true)]
public List<Entry> delegates;
public List<Entry> delegates { get { return triggers; } set { triggers = value; } }

protected EventTrigger()
{}
Expand Down
Loading

0 comments on commit 3bc6a8f

Please sign in to comment.