Ejemplo n.º 1
0
        protected override void ReorientElement(ReorientMethod reorientMethod, int elementsCulledAbove)
        {
            if (ActiveElements.Count <= 1)
            {
                return;
            }

            if (reorientMethod == ReorientMethod.TopToBottom)
            {
                var top = ActiveElements[0];
                ActiveElements.RemoveAt(0);
                ActiveElements.Add(top);

                top.transform.SetSiblingIndex(ActiveElements[ActiveElements.Count - 2].transform.GetSiblingIndex() + 1);
                top.Data = Data[elementsCulledAbove + ActiveElements.Count - 1];
            }
            else
            {
                var bottom = ActiveElements[ActiveElements.Count - 1];
                ActiveElements.RemoveAt(ActiveElements.Count - 1);
                ActiveElements.Insert(0, bottom);

                bottom.transform.SetSiblingIndex(ActiveElements[1].transform.GetSiblingIndex());
                bottom.Data = Data[elementsCulledAbove];
            }
        }
Ejemplo n.º 2
0
        protected override void ReorientElement(ReorientMethod reorientMethod, int elementsCulledAbove)
        {
            if (ActiveElements.Count == 0)
            {
                return;
            }

            var count = Mathf.Abs(elementsCulledAbove - LastElementsCulledAbove);

            if (reorientMethod == ReorientMethod.TopToBottom)
            {
                for (var i = 0; i < count; i++)
                {
                    var top = ActiveElements[0];
                    ActiveElements.RemoveAt(0);
                    ActiveElements.Add(top);

                    top.transform.SetSiblingIndex(ActiveElements[ActiveElements.Count - 2].transform.GetSiblingIndex() + 1);
                    top.Data = Data[elementsCulledAbove + (i + 1 - count) + ActiveElements.Count - 1];
                }
            }
            else
            {
                for (var i = 0; i < count; i++)
                {
                    var bottom = ActiveElements[ActiveElements.Count - 1];
                    ActiveElements.RemoveAt(ActiveElements.Count - 1);
                    ActiveElements.Insert(0, bottom);

                    bottom.transform.SetSiblingIndex(ActiveElements[1].transform.GetSiblingIndex());
                    bottom.Data = Data[elementsCulledAbove - (i + 1 - count)];
                }
            }
        }