namespace EasyLayoutNS { using System; using UnityEngine; /// /// Padding. /// [Serializable] public struct Padding : IEquatable { /// /// The left padding. /// [SerializeField] public float Left; /// /// The right padding. /// [SerializeField] public float Right; /// /// The top padding. /// [SerializeField] public float Top; /// /// The bottom padding. /// [SerializeField] public float Bottom; /// /// Summary horizontal padding. /// public float Horizontal { get { return Left + Right; } } /// /// Summary vertical padding. /// public float Vertical { get { return Top + Bottom; } } /// /// Initializes a new instance of the struct. /// /// Left. /// Right. /// Top. /// Bottom. public Padding(float left, float right, float top, float bottom) { Left = left; Right = right; Top = top; Bottom = bottom; } /// /// Returns a string that represents the current object. /// /// A string that represents the current object. [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0101:Array allocation for params parameter", Justification = "Required.")] public override string ToString() { return string.Format("Padding(left: {0}, right: {1}, top: {2}, bottom: {3})", Left.ToString(), Right.ToString(), Top.ToString(), Bottom.ToString()); } /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. /// true if the specified object is equal to the current object; otherwise, false. public override bool Equals(object obj) { if (obj is Padding) { return Equals((Padding)obj); } return false; } /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. /// true if the specified object is equal to the current object; otherwise, false. public bool Equals(Padding other) { return Left == other.Left && Right == other.Right && Top == other.Top && Bottom == other.Bottom; } /// /// Hash function. /// /// A hash code for the current object. public override int GetHashCode() { return Left.GetHashCode() ^ Right.GetHashCode() ^ Top.GetHashCode() ^ Bottom.GetHashCode(); } /// /// Compare specified paddings. /// /// First padding. /// Second padding. /// true if the paddings are equal; otherwise, false. public static bool operator ==(Padding padding1, Padding padding2) { return padding1.Equals(padding2); } /// /// Compare specified paddings. /// /// First padding. /// Second padding. /// true if the paddings not equal; otherwise, false. public static bool operator !=(Padding padding1, Padding padding2) { return !padding1.Equals(padding2); } } }