Esempio n. 1
0
        public void UpdateListFromOffsets()
        {
            if (SequenceEditor.EditorDragged == null)
            {
                return;
            }

            int currentIndex = SequenceEditor.EditorDragged.Obj.GetId();
            int newIndex     = currentIndex;

            for (int i = 0; i != Editors.Count; ++i)
            {
                if (i == currentIndex)
                {
                    continue;
                }

                if (_editors[i].Offset.target.y > 0)
                {
                    --newIndex;
                }
                else if (_editors[i].Offset.target.y < 0)
                {
                    ++newIndex;
                }
            }

            if (newIndex != currentIndex)
            {
                string undoText = "reorder";

                Undo.SetTransformParent(SequenceEditor.EditorDragged.Obj.transform, ContentTransform, undoText);
                SequenceEditor.EditorDragged.Obj.transform.SetSiblingIndex(newIndex);

                Editors.RemoveAt(currentIndex);
                Editors.Insert(newIndex, (T)SequenceEditor.EditorDragged);
            }
        }