Skip to content

Commit

Permalink
Commit of ui system for 2018.1.9f2
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickfournier committed Dec 6, 2018
1 parent a506132 commit fae7214
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 133 deletions.
2 changes: 1 addition & 1 deletion UnityEditor.UI/EventSystem/EventTriggerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EventTriggerEditor : Editor
protected virtual void OnEnable()
{
m_DelegatesProperty = serializedObject.FindProperty("m_Delegates");
m_AddButonContent = new GUIContent("Add New Event Type");
m_AddButonContent = EditorGUIUtility.TrTextContent("Add New Event Type");
m_EventIDName = new GUIContent("");
// Have to create a copy since otherwise the tooltip will be overwritten.
m_IconToolbarMinus = new GUIContent(EditorGUIUtility.IconContent("Toolbar Minus"));
Expand Down
8 changes: 4 additions & 4 deletions UnityEditor.UI/UI/CanvasScalerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ private class Styles

public Styles()
{
matchContent = new GUIContent("Match");
widthContent = new GUIContent("Width");
heightContent = new GUIContent("Height");
uiScaleModeContent = new GUIContent("UI Scale Mode");
matchContent = EditorGUIUtility.TrTextContent("Match");
widthContent = EditorGUIUtility.TrTextContent("Width");
heightContent = EditorGUIUtility.TrTextContent("Height");
uiScaleModeContent = EditorGUIUtility.TrTextContent("UI Scale Mode");

leftAlignedLabel = new GUIStyle(EditorStyles.label);
rightAlignedLabel = new GUIStyle(EditorStyles.label);
Expand Down
2 changes: 1 addition & 1 deletion UnityEditor.UI/UI/GraphicEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected virtual void OnDisable()

protected virtual void OnEnable()
{
m_CorrectButtonContent = new GUIContent("Set Native Size", "Sets the size to match the content.");
m_CorrectButtonContent = EditorGUIUtility.TrTextContent("Set Native Size", "Sets the size to match the content.");

m_Script = serializedObject.FindProperty("m_Script");
m_Color = serializedObject.FindProperty("m_Color");
Expand Down
12 changes: 6 additions & 6 deletions UnityEditor.UI/UI/HorizontalOrVerticalLayoutGroupEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(m_ChildAlignment, true);

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

rect = EditorGUILayout.GetControlRect();
rect = EditorGUI.PrefixLabel(rect, -1, new GUIContent("Child Force Expand"));
rect = EditorGUI.PrefixLabel(rect, -1, EditorGUIUtility.TrTextContent("Child Force Expand"));
rect.width = Mathf.Max(50, (rect.width - 4) / 3);
EditorGUIUtility.labelWidth = 50;
ToggleLeft(rect, m_ChildForceExpandWidth, new GUIContent("Width"));
ToggleLeft(rect, m_ChildForceExpandWidth, EditorGUIUtility.TrTextContent("Width"));
rect.x += rect.width + 2;
ToggleLeft(rect, m_ChildForceExpandHeight, new GUIContent("Height"));
ToggleLeft(rect, m_ChildForceExpandHeight, EditorGUIUtility.TrTextContent("Height"));
EditorGUIUtility.labelWidth = 0;

serializedObject.ApplyModifiedProperties();
Expand Down
6 changes: 3 additions & 3 deletions UnityEditor.UI/UI/ImageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ protected override void OnEnable()
{
base.OnEnable();

m_SpriteContent = new GUIContent("Source Image");
m_SpriteTypeContent = new GUIContent("Image Type");
m_ClockwiseContent = new GUIContent("Clockwise");
m_SpriteContent = EditorGUIUtility.TrTextContent("Source Image");
m_SpriteTypeContent = EditorGUIUtility.TrTextContent("Image Type");
m_ClockwiseContent = EditorGUIUtility.TrTextContent("Clockwise");

m_Sprite = serializedObject.FindProperty("m_Sprite");
m_Type = serializedObject.FindProperty("m_Type");
Expand Down
2 changes: 1 addition & 1 deletion UnityEditor.UI/UI/InterceptedEventsPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override GUIContent GetPreviewTitle()
{
if (m_Title == null)
{
m_Title = new GUIContent("Intercepted Events");
m_Title = EditorGUIUtility.TrTextContent("Intercepted Events");
}
return m_Title;
}
Expand Down
2 changes: 1 addition & 1 deletion UnityEditor.UI/UI/LayoutPropertiesPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override GUIContent GetPreviewTitle()
{
if (m_Title == null)
{
m_Title = new GUIContent("Layout Properties");
m_Title = EditorGUIUtility.TrTextContent("Layout Properties");
}
return m_Title;
}
Expand Down
4 changes: 2 additions & 2 deletions UnityEditor.UI/UI/PropertyDrawers/FontDataDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static private class Styles

static Styles()
{
m_EncodingContent = new GUIContent("Rich Text", "Use emoticons and colors");
m_EncodingContent = EditorGUIUtility.TrTextContent("Rich Text", "Use emoticons and colors");

// Horizontal Alignment Icons
m_LeftAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_left", "Left Align");
Expand Down Expand Up @@ -241,7 +241,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten

private void DoTextAligmentControl(Rect position, SerializedProperty alignment)
{
GUIContent alingmentContent = new GUIContent("Alignment");
GUIContent alingmentContent = EditorGUIUtility.TrTextContent("Alignment");

int id = EditorGUIUtility.GetControlID(s_TextAlignmentHash, FocusType.Keyboard, position);

Expand Down
2 changes: 1 addition & 1 deletion UnityEditor.UI/UI/PropertyDrawers/NavigationDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private class Styles

public Styles()
{
navigationContent = new GUIContent("Navigation");
navigationContent = EditorGUIUtility.TrTextContent("Navigation");
}
}

Expand Down
2 changes: 1 addition & 1 deletion UnityEditor.UI/UI/RawImageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void OnEnable()
// Note we have precedence for calling rectangle for just rect, even in the Inspector.
// For example in the Camera component's Viewport Rect.
// Hence sticking with Rect here to be consistent with corresponding property in the API.
m_UVRectContent = new GUIContent("UV Rect");
m_UVRectContent = EditorGUIUtility.TrTextContent("UV Rect");

m_Texture = serializedObject.FindProperty("m_Texture");
m_UVRect = serializedObject.FindProperty("m_UVRect");
Expand Down
8 changes: 4 additions & 4 deletions UnityEditor.UI/UI/ScrollRectEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ public override void OnInspectorGUI()
if (m_HorizontalScrollbar.objectReferenceValue && !m_HorizontalScrollbar.hasMultipleDifferentValues)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_HorizontalScrollbarVisibility, new GUIContent("Visibility"));
EditorGUILayout.PropertyField(m_HorizontalScrollbarVisibility, EditorGUIUtility.TrTextContent("Visibility"));

if ((ScrollRect.ScrollbarVisibility)m_HorizontalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport
&& !m_HorizontalScrollbarVisibility.hasMultipleDifferentValues)
{
if (m_ViewportIsNotChild || m_HScrollbarIsNotChild)
EditorGUILayout.HelpBox(s_HError, MessageType.Error);
EditorGUILayout.PropertyField(m_HorizontalScrollbarSpacing, new GUIContent("Spacing"));
EditorGUILayout.PropertyField(m_HorizontalScrollbarSpacing, EditorGUIUtility.TrTextContent("Spacing"));
}

EditorGUI.indentLevel--;
Expand All @@ -149,14 +149,14 @@ public override void OnInspectorGUI()
if (m_VerticalScrollbar.objectReferenceValue && !m_VerticalScrollbar.hasMultipleDifferentValues)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_VerticalScrollbarVisibility, new GUIContent("Visibility"));
EditorGUILayout.PropertyField(m_VerticalScrollbarVisibility, EditorGUIUtility.TrTextContent("Visibility"));

if ((ScrollRect.ScrollbarVisibility)m_VerticalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport
&& !m_VerticalScrollbarVisibility.hasMultipleDifferentValues)
{
if (m_ViewportIsNotChild || m_VScrollbarIsNotChild)
EditorGUILayout.HelpBox(s_VError, MessageType.Error);
EditorGUILayout.PropertyField(m_VerticalScrollbarSpacing, new GUIContent("Spacing"));
EditorGUILayout.PropertyField(m_VerticalScrollbarSpacing, EditorGUIUtility.TrTextContent("Spacing"));
}

EditorGUI.indentLevel--;
Expand Down
2 changes: 1 addition & 1 deletion UnityEditor.UI/UI/SelectableEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SelectableEditor : Editor
SerializedProperty m_AnimTriggerProperty;
SerializedProperty m_NavigationProperty;

GUIContent m_VisualizeNavigation = new GUIContent("Visualize", "Show navigation flows between selectable UI elements.");
GUIContent m_VisualizeNavigation = EditorGUIUtility.TrTextContent("Visualize", "Show navigation flows between selectable UI elements.");

AnimBool m_ShowColorTint = new AnimBool();
AnimBool m_ShowSpriteTrasition = new AnimBool();
Expand Down
2 changes: 0 additions & 2 deletions UnityEditor.UI/UI/SpriteDrawUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ private static void DrawSprite(Texture tex, Rect drawArea, Vector4 padding, Rect

if (mat == null)
{
GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear;
GUI.DrawTextureWithTexCoords(paddedTexArea, tex, uv, true);
GL.sRGBWrite = false;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion UnityEngine.UI/EventSystem/EventSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public bool sendNavigationEvents
}

[SerializeField]
private int m_DragThreshold = 5;
private int m_DragThreshold = 10;
public int pixelDragThreshold
{
get { return m_DragThreshold; }
Expand Down
6 changes: 6 additions & 0 deletions UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public BaseInput input
}
}

public BaseInput inputOverride
{
get { return m_InputOverride; }
set { m_InputOverride = value; }
}

protected EventSystem eventSystem
{
get { return m_EventSystem; }
Expand Down
7 changes: 7 additions & 0 deletions UnityEngine.UI/UI/Core/Dropdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ protected override void Awake()
m_Template.gameObject.SetActive(false);
}

protected override void Start()
{
base.Start();

RefreshShownValue();
}

#if UNITY_EDITOR
protected override void OnValidate()
{
Expand Down
86 changes: 2 additions & 84 deletions UnityEngine.UI/UI/Core/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Text;
using UnityEngine.Serialization;
using UnityEngine.U2D;

namespace UnityEngine.UI
{
Expand Down Expand Up @@ -70,33 +69,11 @@ public enum Origin360

[FormerlySerializedAs("m_Frame")]
[SerializeField] private Sprite m_Sprite;
public Sprite sprite
{
get { return m_Sprite; }
set
{
if (SetPropertyUtility.SetClass(ref m_Sprite, value))
{
SetAllDirty();
TrackSprite();
}
}
}
public Sprite sprite { get { return m_Sprite; } set { if (SetPropertyUtility.SetClass(ref m_Sprite, value)) SetAllDirty(); } }

[NonSerialized]
private Sprite m_OverrideSprite;
public Sprite overrideSprite
{
get { return activeSprite; }
set
{
if (SetPropertyUtility.SetClass(ref m_OverrideSprite, value))
{
SetAllDirty();
TrackSprite();
}
}
}
public Sprite overrideSprite { get { return activeSprite; } set { if (SetPropertyUtility.SetClass(ref m_OverrideSprite, value)) SetAllDirty(); } }

private Sprite activeSprite { get { return m_OverrideSprite != null ? m_OverrideSprite : sprite; } }

Expand Down Expand Up @@ -130,9 +107,6 @@ public Sprite overrideSprite
// Not serialized until we support read-enabled sprites better.
private float m_AlphaHitTestMinimumThreshold = 0;

// Whether this is being tracked for Atlas Binding.
private bool m_Tracked = false;

[Obsolete("eventAlphaThreshold has been deprecated. Use eventMinimumAlphaThreshold instead (UnityUpgradable) -> alphaHitTestMinimumThreshold")]
public float eventAlphaThreshold { get { return 1 - alphaHitTestMinimumThreshold; } set { alphaHitTestMinimumThreshold = 1 - value; } }
public float alphaHitTestMinimumThreshold { get { return m_AlphaHitTestMinimumThreshold; } set { m_AlphaHitTestMinimumThreshold = value; } }
Expand Down Expand Up @@ -336,29 +310,6 @@ protected override void OnPopulateMesh(VertexHelper toFill)
}
}

private void TrackSprite()
{
if (activeSprite != null && activeSprite.texture == null)
{
TrackImage(this);
m_Tracked = true;
}
}

protected override void OnEnable()
{
base.OnEnable();
TrackSprite();
}

protected override void OnDisable()
{
base.OnDisable();

if (m_Tracked)
UnTrackImage(this);
}

/// <summary>
/// Update the renderer's material.
/// </summary>
Expand Down Expand Up @@ -1215,38 +1166,5 @@ private Vector2 MapCoordinate(Vector2 local, Rect rect)

return local;
}

// To track textureless images, which will be rebuild if sprite atlas manager registered a Sprite Atlas that will give this image new texture
static List<Image> m_TrackedTexturelessImages = new List<Image>();
static bool s_Initialized;

static void RebuildImage(SpriteAtlas spriteAtlas)
{
for (var i = m_TrackedTexturelessImages.Count - 1; i >= 0; i--)
{
var g = m_TrackedTexturelessImages[i];
if (spriteAtlas.CanBindTo(g.activeSprite))
{
g.SetAllDirty();
m_TrackedTexturelessImages.RemoveAt(i);
}
}
}

private static void TrackImage(Image g)
{
if (!s_Initialized)
{
SpriteAtlasManager.atlasRegistered += RebuildImage;
s_Initialized = true;
}

m_TrackedTexturelessImages.Add(g);
}

private static void UnTrackImage(Image g)
{
m_TrackedTexturelessImages.Remove(g);
}
}
}
Loading

0 comments on commit fae7214

Please sign in to comment.