public static GameObject GetPreviousSibling(this GameObject current, bool includeInactive = false) { GameObject[] siblings = Locate.GetSiblings(current, true, includeInactive); if (siblings.Length == 0) { return(current); } int previousIndex = siblings.IndexOf(current) - 1; if (previousIndex < 0) { previousIndex = siblings.Length - 1; } return(siblings[previousIndex].gameObject); }
public static GameObject GetNextSibling(this GameObject current, bool includeInactive = false) { GameObject[] siblings = Locate.GetSiblings(current, true, includeInactive); if (siblings.Length == 0) { return(current); } int nextIndex = siblings.IndexOf(current) + 1; if (nextIndex >= siblings.Length) { nextIndex = 0; } return(siblings[nextIndex].gameObject); }
public static int GetSiblingCount(this GameObject current, bool includeInactive = false) { return(Locate.GetSiblings(current, true, includeInactive).Length); }