コード例 #1
0
        private void ChangeIndex(GameObject gameObject, GameObject target, int increment = 0)
        {
            var collection = target?.Parent?.Children ?? SceneData.GameObjects;

            if (!collection.Contains(gameObject))
            {
                MoveTo(gameObject, target?.Parent);
                ChangeIndex(gameObject, target, increment);
                return;
            }

            var oldIndex = Math.Max(collection.IndexOf(gameObject), 0);
            var newIndex = Math.Min(collection.IndexOf(target) + increment, collection.Count);

            if (newIndex > oldIndex)
                newIndex--;

            collection.Move(oldIndex, newIndex);
        }
コード例 #2
0
 public void Drag()
 {
     (Parent?.Children ?? SceneData.GameObjects).Remove(this);
     Parent = null;
 }
コード例 #3
0
 private void MoveTo(GameObject gameObject, GameObject target)
 {
     (gameObject.Parent?.Children ?? SceneData.GameObjects).Remove(gameObject);
     gameObject.Parent = target;
     (target?.Children ?? SceneData.GameObjects).Add(gameObject);
 }