예제 #1
0
        /// <summary>
        /// Compares two behaviours to ensure a consistent ordering when cycling through
        /// info cards.
        /// </summary>
        /// <param name="x">The first behaviour to compare.</param>
        /// <param name="y">The second behaviour to compare.</param>
        /// <returns>negative if the first behaviour is less than the second, positive if the
        /// first is greater than the second, or 0 otherwise.</returns>
        private static int CompareSelectables(KMonoBehaviour x, KMonoBehaviour y)
        {
            int  result;
            bool yn = y == null;

            if (x == null)
            {
                result = yn ? 0 : -1;
            }
            else if (yn)
            {
                result = 1;
            }
            else
            {
                result = x.transform.GetPosition().z.CompareTo(y.transform.GetPosition().z);
                if (result == 0)
                {
                    result = x.GetHashCode().CompareTo(y.GetHashCode());
                }
            }
            return(result);
        }