diff --git a/UnityEditor.UI/UI/MenuOptions.cs b/UnityEditor.UI/UI/MenuOptions.cs index 6d8f2ad..4729b00 100644 --- a/UnityEditor.UI/UI/MenuOptions.cs +++ b/UnityEditor.UI/UI/MenuOptions.cs @@ -79,9 +79,12 @@ private static GameObject CreateUIElementRoot(string name, MenuCommand menuComma { parent = GetOrCreateCanvasGameObject(); } - GameObject child = new GameObject(name); - Undo.RegisterCreatedObjectUndo(child, "Create " + name); + string uniqueName = GameObjectUtility.GetUniqueNameForSibling(parent.transform, name); + + GameObject child = new GameObject(uniqueName); + + Undo.RegisterCreatedObjectUndo(child, "Create " + uniqueName); Undo.SetTransformParent(child.transform, parent.transform, "Parent " + child.name); GameObjectUtility.SetParentAndAlign(child, parent); @@ -99,6 +102,7 @@ private static GameObject CreateUIElementRoot(string name, MenuCommand menuComma static public void AddPanel(MenuCommand menuCommand) { GameObject panelRoot = CreateUIElementRoot("Panel", menuCommand, s_ThickGUIElementSize); + panelRoot.layer = LayerMask.NameToLayer(kUILayerName); // Set RectTransform to stretch RectTransform rectTransform = panelRoot.GetComponent(); diff --git a/UnityEditor.UI/UI/SelectableEditor.cs b/UnityEditor.UI/UI/SelectableEditor.cs index 937561e..73d51d6 100644 --- a/UnityEditor.UI/UI/SelectableEditor.cs +++ b/UnityEditor.UI/UI/SelectableEditor.cs @@ -3,7 +3,6 @@ using System.Linq; using UnityEngine; using UnityEngine.UI; -using UnityEditorInternal; using UnityEditor.AnimatedValues; namespace UnityEditor.UI @@ -164,7 +163,7 @@ public override void OnInspectorGUI() if (animator == null) animator = (target as Selectable).gameObject.AddComponent(); - AnimatorController.SetAnimatorController(animator, controller); + Animations.AnimatorController.SetAnimatorController(animator, controller); } } } @@ -210,7 +209,7 @@ private bool IsDerivedSelectableEditor() return GetType() != typeof(SelectableEditor); } - private static AnimatorController GenerateSelectableAnimatorContoller(AnimationTriggers animationTriggers, Selectable target) + private static Animations.AnimatorController GenerateSelectableAnimatorContoller(AnimationTriggers animationTriggers, Selectable target) { if (target == null) return null; @@ -227,13 +226,14 @@ private static AnimatorController GenerateSelectableAnimatorContoller(AnimationT var disabledName = string.IsNullOrEmpty(animationTriggers.disabledTrigger) ? "Disabled" : animationTriggers.disabledTrigger; // Create controller and hook up transitions. - var controller = AnimatorController.CreateAnimatorControllerAtPath(path); - + var controller = Animations.AnimatorController.CreateAnimatorControllerAtPath(path); GenerateTriggerableTransition(normalName, controller); GenerateTriggerableTransition(highlightedName, controller); GenerateTriggerableTransition(pressedName, controller); GenerateTriggerableTransition(disabledName, controller); + AssetDatabase.ImportAsset(path); + return controller; } @@ -292,24 +292,22 @@ private static string BuildAnimationPath(Selectable target) return animPath.ToString(); } - private static AnimationClip GenerateTriggerableTransition(string name, AnimatorController controller) + private static AnimationClip GenerateTriggerableTransition(string name, Animations.AnimatorController controller) { // Create the clip - var clip = AnimatorController.AllocateAnimatorClip(name); + var clip = Animations.AnimatorController.AllocateAnimatorClip(name); AssetDatabase.AddObjectToAsset(clip, controller); // Create a state in the animatior controller for this clip - var state = AnimatorController.AddAnimationClipToController(controller, clip); + var state = controller.AddMotion(clip); // Add a transition property controller.AddParameter(name, AnimatorControllerParameterType.Trigger); // Add an any state transition - var stateMachine = controller.GetLayer(0).stateMachine; + var stateMachine = controller.layers[0].stateMachine; var transition = stateMachine.AddAnyStateTransition(state); - var condition = transition.GetCondition(0); - condition.mode = TransitionConditionMode.If; - condition.parameter = name; + transition.AddCondition(Animations.AnimatorConditionMode.If, 0, name); return clip; } diff --git a/UnityEngine.UI/EventSystem/EventSystem.cs b/UnityEngine.UI/EventSystem/EventSystem.cs index cf30e83..2a60b90 100644 --- a/UnityEngine.UI/EventSystem/EventSystem.cs +++ b/UnityEngine.UI/EventSystem/EventSystem.cs @@ -63,7 +63,7 @@ public GameObject lastSelectedGameObject } protected EventSystem() - { } + {} public void UpdateModules() { diff --git a/UnityEngine.UI/EventSystem/EventTrigger.cs b/UnityEngine.UI/EventSystem/EventTrigger.cs index 4aff21a..225f407 100644 --- a/UnityEngine.UI/EventSystem/EventTrigger.cs +++ b/UnityEngine.UI/EventSystem/EventTrigger.cs @@ -27,7 +27,7 @@ public class EventTrigger : { [Serializable] public class TriggerEvent : UnityEvent - { } + {} [Serializable] public class Entry @@ -39,7 +39,7 @@ public class Entry public List delegates; protected EventTrigger() - { } + {} private void Execute(EventTriggerType id, BaseEventData eventData) { diff --git a/UnityEngine.UI/EventSystem/ExecuteEvents.cs b/UnityEngine.UI/EventSystem/ExecuteEvents.cs index 608e571..ffe1f14 100644 --- a/UnityEngine.UI/EventSystem/ExecuteEvents.cs +++ b/UnityEngine.UI/EventSystem/ExecuteEvents.cs @@ -8,7 +8,7 @@ public static class ExecuteEvents { public delegate void EventFunction(T1 handler, BaseEventData eventData); - public static T ValidateEventData(BaseEventData data) where T: class + public static T ValidateEventData(BaseEventData data) where T : class { if ((data as T) == null) throw new ArgumentException(String.Format("Invalid type: {0} passed to event expecting {1}", data.GetType(), typeof(T))); @@ -243,12 +243,12 @@ private static void GetEventChain(GameObject root, IList eventChain) private static readonly ObjectPool> s_HandlerListPool = new ObjectPool>(null, l => l.Clear()); - public static bool Execute(GameObject target, BaseEventData eventData, EventFunction functor) where T: IEventSystemHandler + public static bool Execute(GameObject target, BaseEventData eventData, EventFunction functor) where T : IEventSystemHandler { var internalHandlers = s_HandlerListPool.Get(); GetEventList(target, internalHandlers); - // if (s_InternalHandlers.Count > 0) - // Debug.Log("Executinng " + typeof (T) + " on " + target); + // if (s_InternalHandlers.Count > 0) + // Debug.Log("Executinng " + typeof (T) + " on " + target); for (var i = 0; i < internalHandlers.Count; i++) { @@ -284,7 +284,7 @@ public static bool Execute(GameObject target, BaseEventData eventData, EventF /// private static readonly List s_InternalTransformList = new List(30); - public static GameObject ExecuteHierarchy(GameObject root, BaseEventData eventData, EventFunction callbackFunction) where T: IEventSystemHandler + public static GameObject ExecuteHierarchy(GameObject root, BaseEventData eventData, EventFunction callbackFunction) where T : IEventSystemHandler { GetEventChain(root, s_InternalTransformList); @@ -297,7 +297,7 @@ public static GameObject ExecuteHierarchy(GameObject root, BaseEventData even return null; } - private static bool ShouldSendToComponent(Component component) where T: IEventSystemHandler + private static bool ShouldSendToComponent(Component component) where T : IEventSystemHandler { var valid = component is T; if (!valid) @@ -312,7 +312,7 @@ private static bool ShouldSendToComponent(Component component) where T: IEven /// /// Get the specified object's event event. /// - private static void GetEventList(GameObject go, IList results) where T: IEventSystemHandler + private static void GetEventList(GameObject go, IList results) where T : IEventSystemHandler { // Debug.LogWarning("GetEventList<" + typeof(T).Name + ">"); if (results == null) @@ -338,7 +338,7 @@ private static void GetEventList(GameObject go, IList re /// /// Whether the specified game object will be able to handle the specified event. /// - public static bool CanHandleEvent(GameObject go) where T: IEventSystemHandler + public static bool CanHandleEvent(GameObject go) where T : IEventSystemHandler { var internalHandlers = s_HandlerListPool.Get(); GetEventList(go, internalHandlers); @@ -350,7 +350,7 @@ public static bool CanHandleEvent(GameObject go) where T: IEventSystemHandler /// /// Bubble the specified event on the game object, figuring out which object will actually receive the event. /// - public static GameObject GetEventHandler(GameObject root) where T: IEventSystemHandler + public static GameObject GetEventHandler(GameObject root) where T : IEventSystemHandler { if (root == null) return null; diff --git a/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs b/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs index faccb19..710b899 100644 --- a/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs +++ b/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs @@ -106,7 +106,7 @@ protected void HandlePointerExitAndEnter(PointerEventData currentPointerData, Ga GameObject commonRoot = FindCommonRoot(currentPointerData.pointerEnter, newEnterTarget); #if UNITY_EDITOR - // lastCommonRoot = commonRoot; + // lastCommonRoot = commonRoot; #endif // and we already an entered object from last time if (currentPointerData.pointerEnter != null) @@ -171,13 +171,13 @@ public virtual bool ShouldActivateModule() } public virtual void DeactivateModule() - { } + {} public virtual void ActivateModule() - { } + {} public virtual void UpdateModule() - { } + {} public virtual bool IsModuleSupported() { diff --git a/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs b/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs index b1259c2..1b653a7 100644 --- a/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs +++ b/UnityEngine.UI/EventSystem/InputModules/PointerInputModule.cs @@ -70,6 +70,8 @@ private void CopyFromTo(PointerEventData @from, PointerEventData @to) @to.scrollDelta = @from.scrollDelta; @to.pointerCurrentRaycast = @from.pointerCurrentRaycast; @to.pointerEnter = @from.pointerEnter; + @to.worldPosition = @from.worldPosition; + @to.worldNormal = @from.worldNormal; } protected static PointerEventData.FramePressState StateForMouseButton(int buttonId) diff --git a/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs b/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs index 50dc734..1e6be91 100644 --- a/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs +++ b/UnityEngine.UI/EventSystem/InputModules/StandaloneInputModule.cs @@ -11,7 +11,7 @@ public class StandaloneInputModule : PointerInputModule private Vector2 m_MousePosition; protected StandaloneInputModule() - { } + {} [Obsolete("Mode is no longer needed on input module as it handles both mouse and keyboard simultaneously.", false)] public enum InputMode diff --git a/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs b/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs index 5791369..89726cd 100644 --- a/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs +++ b/UnityEngine.UI/EventSystem/InputModules/TouchInputModule.cs @@ -6,7 +6,7 @@ namespace UnityEngine.EventSystems public class TouchInputModule : PointerInputModule { protected TouchInputModule() - { } + {} private Vector2 m_LastMousePosition; private Vector2 m_MousePosition; diff --git a/UnityEngine.UI/EventSystem/RaycastResult.cs b/UnityEngine.UI/EventSystem/RaycastResult.cs index 3e17548..30d6d08 100644 --- a/UnityEngine.UI/EventSystem/RaycastResult.cs +++ b/UnityEngine.UI/EventSystem/RaycastResult.cs @@ -34,7 +34,7 @@ public void Clear() public override string ToString() { return "Name: " + gameObject.name + "\n" + - "module: " + module.camera + "\n" + + "module: " + module.GetComponent() + "\n" + "distance: " + distance + "\n" + "index: " + index + "\n" + "depth: " + depth + "\n" + diff --git a/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs b/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs index 627959d..8cae763 100644 --- a/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs +++ b/UnityEngine.UI/EventSystem/Raycasters/Physics2DRaycaster.cs @@ -10,7 +10,7 @@ namespace UnityEngine.EventSystems public class Physics2DRaycaster : PhysicsRaycaster { protected Physics2DRaycaster() - { } + {} public override void Raycast(PointerEventData eventData, List resultAppendList) { diff --git a/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs b/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs index 48ae98a..b2fa4bc 100644 --- a/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs +++ b/UnityEngine.UI/EventSystem/Raycasters/PhysicsRaycaster.cs @@ -23,7 +23,7 @@ public class PhysicsRaycaster : BaseRaycaster protected LayerMask m_EventMask = kNoEventMaskSet; protected PhysicsRaycaster() - { } + {} public override Camera eventCamera { diff --git a/UnityEngine.UI/EventSystem/UIBehaviour.cs b/UnityEngine.UI/EventSystem/UIBehaviour.cs index 46c0ae8..37e8fc5 100644 --- a/UnityEngine.UI/EventSystem/UIBehaviour.cs +++ b/UnityEngine.UI/EventSystem/UIBehaviour.cs @@ -3,19 +3,19 @@ namespace UnityEngine.EventSystems public abstract class UIBehaviour : MonoBehaviour { protected virtual void Awake() - { } + {} protected virtual void OnEnable() - { } + {} protected virtual void Start() - { } + {} protected virtual void OnDisable() - { } + {} protected virtual void OnDestroy() - { } + {} public virtual bool IsActive() { @@ -24,26 +24,26 @@ public virtual bool IsActive() #if UNITY_EDITOR protected virtual void OnValidate() - { } + {} protected virtual void Reset() - { } + {} #endif protected virtual void OnRectTransformDimensionsChange() - { } + {} protected virtual void OnBeforeTransformParentChanged() - { } + {} protected virtual void OnTransformParentChanged() - { } + {} protected virtual void OnDidApplyAnimationProperties() - { } + {} protected virtual void OnCanvasGroupChanged() - { } + {} public bool IsDestroyed() { diff --git a/UnityEngine.UI/UI/Animation/CoroutineTween.cs b/UnityEngine.UI/UI/Animation/CoroutineTween.cs index aa2f526..0538fe1 100644 --- a/UnityEngine.UI/UI/Animation/CoroutineTween.cs +++ b/UnityEngine.UI/UI/Animation/CoroutineTween.cs @@ -27,7 +27,7 @@ public enum ColorTweenMode Alpha } - public class ColorTweenCallback : UnityEvent { } + public class ColorTweenCallback : UnityEvent {} private ColorTweenCallback m_Target; private Color m_StartColor; diff --git a/UnityEngine.UI/UI/Core/Button.cs b/UnityEngine.UI/UI/Core/Button.cs index 29d3f6c..de9608a 100644 --- a/UnityEngine.UI/UI/Core/Button.cs +++ b/UnityEngine.UI/UI/Core/Button.cs @@ -11,7 +11,7 @@ namespace UnityEngine.UI public class Button : Selectable, IPointerClickHandler, ISubmitHandler { [Serializable] - public class ButtonClickedEvent : UnityEvent { } + public class ButtonClickedEvent : UnityEvent {} // Event delegates triggered on click. [FormerlySerializedAs("onClick")] @@ -19,7 +19,7 @@ public class ButtonClickedEvent : UnityEvent { } private ButtonClickedEvent m_OnClick = new ButtonClickedEvent(); protected Button() - { } + {} public ButtonClickedEvent onClick { diff --git a/UnityEngine.UI/UI/Core/FontData.cs b/UnityEngine.UI/UI/Core/FontData.cs index 764ee8a..0b72deb 100644 --- a/UnityEngine.UI/UI/Core/FontData.cs +++ b/UnityEngine.UI/UI/Core/FontData.cs @@ -8,7 +8,7 @@ namespace UnityEngine.UI /// [Serializable] - public struct FontData : ISerializationCallbackReceiver + public class FontData : ISerializationCallbackReceiver { [SerializeField] [FormerlySerializedAs("font")] @@ -136,7 +136,7 @@ public float lineSpacing } void ISerializationCallbackReceiver.OnBeforeSerialize() - { } + {} void ISerializationCallbackReceiver.OnAfterDeserialize() { diff --git a/UnityEngine.UI/UI/Core/FontUpdateTracker.cs b/UnityEngine.UI/UI/Core/FontUpdateTracker.cs index 28eb6b0..900cb77 100644 --- a/UnityEngine.UI/UI/Core/FontUpdateTracker.cs +++ b/UnityEngine.UI/UI/Core/FontUpdateTracker.cs @@ -20,7 +20,7 @@ public static void TrackText(Text t) exists = new List(); m_Tracked.Add(t.font, exists); - t.font.textureRebuildCallback += RebuildForFont(t.font); + Font.textureRebuilt += RebuildForFont; } for (int i = 0; i < exists.Count; i++) @@ -32,19 +32,16 @@ public static void TrackText(Text t) exists.Add(t); } - private static Font.FontTextureRebuildCallback RebuildForFont(Font f) + private static void RebuildForFont(Font f) { - return () => - { - List texts; - m_Tracked.TryGetValue(f, out texts); + List texts; + m_Tracked.TryGetValue(f, out texts); - if (texts == null) - return; + if (texts == null) + return; - for (var i = 0; i < texts.Count; i++) - texts[i].FontTextureChanged(); - }; + for (var i = 0; i < texts.Count; i++) + texts[i].FontTextureChanged(); } public static void UntrackText(Text t) diff --git a/UnityEngine.UI/UI/Core/Graphic.cs b/UnityEngine.UI/UI/Core/Graphic.cs index 3d567f7..8843f6b 100644 --- a/UnityEngine.UI/UI/Core/Graphic.cs +++ b/UnityEngine.UI/UI/Core/Graphic.cs @@ -386,7 +386,7 @@ protected override void OnDidApplyAnimationProperties() /// /// Make the Graphic have the native size of its content. /// - public virtual void SetNativeSize() { } + public virtual void SetNativeSize() {} public virtual bool Raycast(Vector2 sp, Camera eventCamera) { var t = transform; diff --git a/UnityEngine.UI/UI/Core/GraphicRaycaster.cs b/UnityEngine.UI/UI/Core/GraphicRaycaster.cs index 7222e9d..30bc1c0 100644 --- a/UnityEngine.UI/UI/Core/GraphicRaycaster.cs +++ b/UnityEngine.UI/UI/Core/GraphicRaycaster.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using UnityEngine.EventSystems; +using UnityEngine.Serialization; namespace UnityEngine.UI { @@ -42,8 +43,10 @@ public override int renderOrderPriority } } + [FormerlySerializedAs("ignoreReversedGraphics")] [SerializeField] private bool m_IgnoreReversedGraphics = true; + [FormerlySerializedAs("blockingObjects")] [SerializeField] private BlockingObjects m_BlockingObjects = BlockingObjects.None; @@ -56,7 +59,7 @@ public override int renderOrderPriority private Canvas m_Canvas; protected GraphicRaycaster() - { } + {} private Canvas canvas { @@ -217,10 +220,10 @@ private static void Raycast(Canvas canvas, Camera eventCamera, Vector2 pointerPo } s_SortedGraphics.Sort((g1, g2) => g2.depth.CompareTo(g1.depth)); - // StringBuilder cast = new StringBuilder(); + // StringBuilder cast = new StringBuilder(); for (int i = 0; i < s_SortedGraphics.Count; ++i) results.Add(s_SortedGraphics[i]); - // Debug.Log (cast.ToString()); + // Debug.Log (cast.ToString()); } } } diff --git a/UnityEngine.UI/UI/Core/Image.cs b/UnityEngine.UI/UI/Core/Image.cs index c10f8fa..5c4382f 100644 --- a/UnityEngine.UI/UI/Core/Image.cs +++ b/UnityEngine.UI/UI/Core/Image.cs @@ -104,7 +104,7 @@ public enum Origin360 public float eventAlphaThreshold { get { return m_EventAlphaThreshold; } set { m_EventAlphaThreshold = value; } } protected Image() - { } + {} /// /// Image's texture comes from the UnityEngine.Image. @@ -150,7 +150,7 @@ public float pixelsPerUnit } } - public virtual void OnBeforeSerialize() { } + public virtual void OnBeforeSerialize() {} public virtual void OnAfterDeserialize() { @@ -851,8 +851,8 @@ static void RadialCut(Vector2[] xy, float cos, float sin, bool invert, int corne #endregion - public virtual void CalculateLayoutInputHorizontal() { } - public virtual void CalculateLayoutInputVertical() { } + public virtual void CalculateLayoutInputHorizontal() {} + public virtual void CalculateLayoutInputVertical() {} public virtual float minWidth { get { return 0; } } diff --git a/UnityEngine.UI/UI/Core/InputField.cs b/UnityEngine.UI/UI/Core/InputField.cs index b51ac9f..feb7f57 100644 --- a/UnityEngine.UI/UI/Core/InputField.cs +++ b/UnityEngine.UI/UI/Core/InputField.cs @@ -64,10 +64,10 @@ public enum LineType public delegate char OnValidateInput(string text, int charIndex, char addedChar); [Serializable] - public class SubmitEvent : UnityEvent { } + public class SubmitEvent : UnityEvent {} [Serializable] - public class OnChangeEvent : UnityEvent { } + public class OnChangeEvent : UnityEvent {} static protected TouchScreenKeyboard m_Keyboard; static private readonly char[] kSeparators = { ' ', '.', ',' }; @@ -200,7 +200,7 @@ public class OnChangeEvent : UnityEvent { } const string kEmailSpecialCharacters = "!#$%&'*+-/=?^_`{|}~"; protected InputField() - { } + {} protected TextGenerator cachedInputTextGenerator @@ -1450,6 +1450,7 @@ private void SetDrawRangeToContainCaretPosition(TextGenerator gen, int caretPos, if (height < lines[startLine].height) break; drawStart = GetLineStartPosition(gen, startLine); + height -= lines[startLine].height; } else diff --git a/UnityEngine.UI/UI/Core/Layout/AspectRatioFitter.cs b/UnityEngine.UI/UI/Core/Layout/AspectRatioFitter.cs index bb81bb6..1d15328 100644 --- a/UnityEngine.UI/UI/Core/Layout/AspectRatioFitter.cs +++ b/UnityEngine.UI/UI/Core/Layout/AspectRatioFitter.cs @@ -30,7 +30,7 @@ private RectTransform rectTransform private DrivenRectTransformTracker m_Tracker; - protected AspectRatioFitter() { } + protected AspectRatioFitter() {} #region Unity Lifetime calls @@ -127,9 +127,9 @@ private Vector2 GetParentSize() return parent.rect.size; } - public virtual void SetLayoutHorizontal() { } + public virtual void SetLayoutHorizontal() {} - public virtual void SetLayoutVertical() { } + public virtual void SetLayoutVertical() {} protected void SetDirty() { diff --git a/UnityEngine.UI/UI/Core/Layout/CanvasScaler.cs b/UnityEngine.UI/UI/Core/Layout/CanvasScaler.cs index 23707a8..9b5ef14 100644 --- a/UnityEngine.UI/UI/Core/Layout/CanvasScaler.cs +++ b/UnityEngine.UI/UI/Core/Layout/CanvasScaler.cs @@ -79,7 +79,7 @@ public enum Unit { Centimeters, Millimeters, Inches, Points, Picas } private float m_PrevReferencePixelsPerUnit = 100; - protected CanvasScaler() { } + protected CanvasScaler() {} protected override void OnEnable() { diff --git a/UnityEngine.UI/UI/Core/Layout/ContentSizeFitter.cs b/UnityEngine.UI/UI/Core/Layout/ContentSizeFitter.cs index 22a3367..c326a44 100644 --- a/UnityEngine.UI/UI/Core/Layout/ContentSizeFitter.cs +++ b/UnityEngine.UI/UI/Core/Layout/ContentSizeFitter.cs @@ -34,7 +34,7 @@ private RectTransform rectTransform private DrivenRectTransformTracker m_Tracker; protected ContentSizeFitter() - { } + {} #region Unity Lifetime calls diff --git a/UnityEngine.UI/UI/Core/Layout/GridLayoutGroup.cs b/UnityEngine.UI/UI/Core/Layout/GridLayoutGroup.cs index 50f9e5f..017865a 100644 --- a/UnityEngine.UI/UI/Core/Layout/GridLayoutGroup.cs +++ b/UnityEngine.UI/UI/Core/Layout/GridLayoutGroup.cs @@ -29,7 +29,7 @@ public enum Constraint { Flexible = 0, FixedColumnCount = 1, FixedRowCount = 2 } public int constraintCount { get { return m_ConstraintCount; } set { SetProperty(ref m_ConstraintCount, value); } } protected GridLayoutGroup() - { } + {} public override void CalculateLayoutInputHorizontal() { diff --git a/UnityEngine.UI/UI/Core/Layout/HorizontalLayoutGroup.cs b/UnityEngine.UI/UI/Core/Layout/HorizontalLayoutGroup.cs index 93f977f..efe8d8e 100644 --- a/UnityEngine.UI/UI/Core/Layout/HorizontalLayoutGroup.cs +++ b/UnityEngine.UI/UI/Core/Layout/HorizontalLayoutGroup.cs @@ -4,7 +4,7 @@ namespace UnityEngine.UI public class HorizontalLayoutGroup : HorizontalOrVerticalLayoutGroup { protected HorizontalLayoutGroup() - { } + {} public override void CalculateLayoutInputHorizontal() { diff --git a/UnityEngine.UI/UI/Core/Layout/LayoutElement.cs b/UnityEngine.UI/UI/Core/Layout/LayoutElement.cs index 715f1b0..dfcb35c 100644 --- a/UnityEngine.UI/UI/Core/Layout/LayoutElement.cs +++ b/UnityEngine.UI/UI/Core/Layout/LayoutElement.cs @@ -20,8 +20,8 @@ public class LayoutElement : UIBehaviour, ILayoutElement, ILayoutIgnorer public virtual bool ignoreLayout { get { return m_IgnoreLayout; } set { if (SetPropertyUtility.SetStruct(ref m_IgnoreLayout, value)) SetDirty(); } } - public virtual void CalculateLayoutInputHorizontal() { } - public virtual void CalculateLayoutInputVertical() { } + public virtual void CalculateLayoutInputHorizontal() {} + public virtual void CalculateLayoutInputVertical() {} public virtual float minWidth { get { return m_MinWidth; } set { if (SetPropertyUtility.SetStruct(ref m_MinWidth, value)) SetDirty(); } } public virtual float minHeight { get { return m_MinHeight; } set { if (SetPropertyUtility.SetStruct(ref m_MinHeight, value)) SetDirty(); } } public virtual float preferredWidth { get { return m_PreferredWidth; } set { if (SetPropertyUtility.SetStruct(ref m_PreferredWidth, value)) SetDirty(); } } @@ -32,7 +32,7 @@ public virtual void CalculateLayoutInputVertical() { } protected LayoutElement() - { } + {} #region Unity Lifetime calls diff --git a/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs b/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs index acc947d..75a9bc4 100644 --- a/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs +++ b/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs @@ -7,10 +7,18 @@ namespace UnityEngine.UI public struct LayoutRebuilder : ICanvasElement, IEquatable { private readonly RectTransform m_ToRebuild; + //There are a few of reasons we need to cache the Hash fromt he transform: + // - This is a ValueType (struct) and .Net calculates Hash from the Value Type fields. + // - The key of a Dictionary should have a constant Hash value. + // - It's possible for the Transform to get nulled from the Native side. + // We use this struct with the IndexedSet container, which uses a dictionary as part of it's implementation + // So this struct gets used as a key to a dictionary, so we need to guarantee a constant Hash value. + private readonly int m_CachedHasFromTrasnform; private LayoutRebuilder(RectTransform controller) { m_ToRebuild = controller; + m_CachedHasFromTrasnform = m_ToRebuild.GetHashCode(); } static LayoutRebuilder() @@ -172,6 +180,11 @@ public bool Equals(LayoutRebuilder other) return m_ToRebuild == other.m_ToRebuild; } + public override int GetHashCode() + { + return m_CachedHasFromTrasnform; + } + public override string ToString() { return "(Layout Rebuilder for) " + m_ToRebuild; diff --git a/UnityEngine.UI/UI/Core/Layout/VerticalLayoutGroup.cs b/UnityEngine.UI/UI/Core/Layout/VerticalLayoutGroup.cs index 2498025..e24b842 100644 --- a/UnityEngine.UI/UI/Core/Layout/VerticalLayoutGroup.cs +++ b/UnityEngine.UI/UI/Core/Layout/VerticalLayoutGroup.cs @@ -4,7 +4,7 @@ namespace UnityEngine.UI public class VerticalLayoutGroup : HorizontalOrVerticalLayoutGroup { protected VerticalLayoutGroup() - { } + {} public override void CalculateLayoutInputHorizontal() { diff --git a/UnityEngine.UI/UI/Core/MaterialModifiers/Mask.cs b/UnityEngine.UI/UI/Core/MaterialModifiers/Mask.cs index 350d83a..bfca56e 100644 --- a/UnityEngine.UI/UI/Core/MaterialModifiers/Mask.cs +++ b/UnityEngine.UI/UI/Core/MaterialModifiers/Mask.cs @@ -49,7 +49,7 @@ public RectTransform rectTransform } protected Mask() - { } + {} public virtual bool MaskEnabled() { diff --git a/UnityEngine.UI/UI/Core/RawImage.cs b/UnityEngine.UI/UI/Core/RawImage.cs index c5a466c..1c2e6de 100644 --- a/UnityEngine.UI/UI/Core/RawImage.cs +++ b/UnityEngine.UI/UI/Core/RawImage.cs @@ -16,7 +16,7 @@ public class RawImage : MaskableGraphic [SerializeField] Rect m_UVRect = new Rect(0f, 0f, 1f, 1f); protected RawImage() - { } + {} /// /// Returns the texture used to draw this Graphic. diff --git a/UnityEngine.UI/UI/Core/ScrollRect.cs b/UnityEngine.UI/UI/Core/ScrollRect.cs index 85eaab0..572fc67 100644 --- a/UnityEngine.UI/UI/Core/ScrollRect.cs +++ b/UnityEngine.UI/UI/Core/ScrollRect.cs @@ -18,7 +18,7 @@ public enum MovementType } [Serializable] - public class ScrollRectEvent : UnityEvent { } + public class ScrollRectEvent : UnityEvent {} [SerializeField] private RectTransform m_Content; @@ -123,7 +123,7 @@ protected RectTransform viewRect private bool m_HasRebuiltLayout = false; protected ScrollRect() - { } + {} public virtual void Rebuild(CanvasUpdate executing) { diff --git a/UnityEngine.UI/UI/Core/Scrollbar.cs b/UnityEngine.UI/UI/Core/Scrollbar.cs index 7333db5..e2c3ef9 100644 --- a/UnityEngine.UI/UI/Core/Scrollbar.cs +++ b/UnityEngine.UI/UI/Core/Scrollbar.cs @@ -18,7 +18,7 @@ public enum Direction } [Serializable] - public class ScrollEvent : UnityEvent { } + public class ScrollEvent : UnityEvent {} [SerializeField] private RectTransform m_HandleRect; @@ -30,7 +30,7 @@ public class ScrollEvent : UnityEvent { } public Direction direction { get { return m_Direction; } set { if (SetPropertyUtility.SetStruct(ref m_Direction, value)) UpdateVisuals(); } } protected Scrollbar() - { } + {} // Scroll bar's current value in 0 to 1 range. [Range(0f, 1f)] diff --git a/UnityEngine.UI/UI/Core/Selectable.cs b/UnityEngine.UI/UI/Core/Selectable.cs index 8aa31ea..21cb0a1 100644 --- a/UnityEngine.UI/UI/Core/Selectable.cs +++ b/UnityEngine.UI/UI/Core/Selectable.cs @@ -85,7 +85,7 @@ public enum Transition private bool hasSelection { get; set; } protected Selectable() - { } + {} // Convenience function that converts the Graphic to a Image, if possible public Image image diff --git a/UnityEngine.UI/UI/Core/SetPropertyUtility.cs b/UnityEngine.UI/UI/Core/SetPropertyUtility.cs index 8ff552b..932e618 100644 --- a/UnityEngine.UI/UI/Core/SetPropertyUtility.cs +++ b/UnityEngine.UI/UI/Core/SetPropertyUtility.cs @@ -13,7 +13,7 @@ public static bool SetColor(ref Color currentValue, Color newValue) return true; } - public static bool SetStruct(ref T currentValue, T newValue) where T: struct + public static bool SetStruct(ref T currentValue, T newValue) where T : struct { if (currentValue.Equals(newValue)) return false; @@ -22,7 +22,7 @@ public static bool SetStruct(ref T currentValue, T newValue) where T: struct return true; } - public static bool SetClass(ref T currentValue, T newValue) where T: class + public static bool SetClass(ref T currentValue, T newValue) where T : class { if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue))) return false; diff --git a/UnityEngine.UI/UI/Core/Slider.cs b/UnityEngine.UI/UI/Core/Slider.cs index 20e9cd6..21466ac 100644 --- a/UnityEngine.UI/UI/Core/Slider.cs +++ b/UnityEngine.UI/UI/Core/Slider.cs @@ -17,7 +17,7 @@ public enum Direction } [Serializable] - public class SliderEvent : UnityEvent { } + public class SliderEvent : UnityEvent {} [SerializeField] private RectTransform m_FillRect; @@ -99,7 +99,7 @@ public float normalizedValue float stepSize { get { return wholeNumbers ? 1 : (maxValue - minValue) * 0.1f; } } protected Slider() - { } + {} #if UNITY_EDITOR protected override void OnValidate() diff --git a/UnityEngine.UI/UI/Core/Text.cs b/UnityEngine.UI/UI/Core/Text.cs index 1a40c18..67da2f5 100644 --- a/UnityEngine.UI/UI/Core/Text.cs +++ b/UnityEngine.UI/UI/Core/Text.cs @@ -21,10 +21,10 @@ public class Text : MaskableGraphic, ILayoutElement static protected Material s_DefaultText = null; // We use this flag instead of Unregistering/Registering the callback to avoid allocation. - [NonSerialized] private bool m_DisableFontTextureChangedCallback = false; + [NonSerialized] private bool m_DisableFontTextureRebuiltCallback = false; protected Text() - { } + {} /// /// Get or set the material used by this Text. @@ -76,7 +76,7 @@ public void FontTextureChanged() return; } - if (m_DisableFontTextureChangedCallback) + if (m_DisableFontTextureRebuiltCallback) return; cachedTextGenerator.Invalidate(); @@ -432,7 +432,7 @@ protected override void OnFillVBO(List vbo) // We dont care if we the font Texture changes while we are doing our Update. // The end result of cachedTextGenerator will be valid for this instance. // Otherwise we can get issues like Case 619238. - m_DisableFontTextureChangedCallback = true; + m_DisableFontTextureRebuiltCallback = true; Vector2 extents = rectTransform.rect.size; @@ -473,11 +473,11 @@ protected override void OnFillVBO(List vbo) vbo.Add(uiv); } } - m_DisableFontTextureChangedCallback = false; + m_DisableFontTextureRebuiltCallback = false; } - public virtual void CalculateLayoutInputHorizontal() { } - public virtual void CalculateLayoutInputVertical() { } + public virtual void CalculateLayoutInputHorizontal() {} + public virtual void CalculateLayoutInputVertical() {} public virtual float minWidth { diff --git a/UnityEngine.UI/UI/Core/Toggle.cs b/UnityEngine.UI/UI/Core/Toggle.cs index 1763836..284d9ec 100644 --- a/UnityEngine.UI/UI/Core/Toggle.cs +++ b/UnityEngine.UI/UI/Core/Toggle.cs @@ -20,7 +20,7 @@ public enum ToggleTransition [Serializable] public class ToggleEvent : UnityEvent - { } + {} /// /// Transition type. @@ -64,7 +64,7 @@ public ToggleGroup group private bool m_IsOn; protected Toggle() - { } + {} #if UNITY_EDITOR protected override void OnValidate() diff --git a/UnityEngine.UI/UI/Core/ToggleGroup.cs b/UnityEngine.UI/UI/Core/ToggleGroup.cs index 0154f3f..e678958 100644 --- a/UnityEngine.UI/UI/Core/ToggleGroup.cs +++ b/UnityEngine.UI/UI/Core/ToggleGroup.cs @@ -14,12 +14,12 @@ public class ToggleGroup : UIBehaviour private List m_Toggles = new List(); protected ToggleGroup() - { } + {} private void ValidateToggleIsInGroup(Toggle toggle) { if (toggle == null || !m_Toggles.Contains(toggle)) - throw new ArgumentException(string.Format("Toggle {0} is not part of ToggleGroup {1}", toggle, this)); + throw new ArgumentException(string.Format("Toggle {0} is not part of ToggleGroup {1}", new object[] {toggle, this})); } public void NotifyToggleOn(Toggle toggle) diff --git a/UnityEngine.UI/UI/Core/VertexModifiers/Outline.cs b/UnityEngine.UI/UI/Core/VertexModifiers/Outline.cs index 366d706..3d89255 100644 --- a/UnityEngine.UI/UI/Core/VertexModifiers/Outline.cs +++ b/UnityEngine.UI/UI/Core/VertexModifiers/Outline.cs @@ -6,7 +6,7 @@ namespace UnityEngine.UI public class Outline : Shadow { protected Outline() - { } + {} public override void ModifyVertices(List verts) { diff --git a/UnityEngine.UI/UI/Core/VertexModifiers/PositionAsUV1.cs b/UnityEngine.UI/UI/Core/VertexModifiers/PositionAsUV1.cs index dc9ca26..a3a0c5c 100644 --- a/UnityEngine.UI/UI/Core/VertexModifiers/PositionAsUV1.cs +++ b/UnityEngine.UI/UI/Core/VertexModifiers/PositionAsUV1.cs @@ -6,7 +6,7 @@ namespace UnityEngine.UI public class PositionAsUV1 : BaseVertexEffect { protected PositionAsUV1() - { } + {} public override void ModifyVertices(List verts) { diff --git a/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs b/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs index ac7c250..88bc5ff 100644 --- a/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs +++ b/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs @@ -15,7 +15,7 @@ public class Shadow : BaseVertexEffect private bool m_UseGraphicAlpha = true; protected Shadow() - { } + {} #if UNITY_EDITOR protected override void OnValidate() diff --git a/lib/UnityEditor.dll b/lib/UnityEditor.dll index 469d5ac..3ea58ed 100644 Binary files a/lib/UnityEditor.dll and b/lib/UnityEditor.dll differ diff --git a/lib/UnityEditor.dll.mdb b/lib/UnityEditor.dll.mdb index 0824fa3..5093d17 100644 Binary files a/lib/UnityEditor.dll.mdb and b/lib/UnityEditor.dll.mdb differ diff --git a/lib/UnityEngine.dll b/lib/UnityEngine.dll index c8c820d..96a476d 100644 Binary files a/lib/UnityEngine.dll and b/lib/UnityEngine.dll differ diff --git a/lib/UnityEngine.dll.mdb b/lib/UnityEngine.dll.mdb index 5bf9b3d..15a43d1 100644 Binary files a/lib/UnityEngine.dll.mdb and b/lib/UnityEngine.dll.mdb differ