//
        // Checks the changes in the selected elements and updates the gizmos.
        //
        private void OnSelectionUpdated(object sender, [NotNull] EntitySelectionEventArgs e)
        {
            var previousSelection = new HashSet <Entity>(e.OldSelection);

            foreach (var childEntity in e.OldSelection.SelectDeep(x => x.Transform.Children.Select(y => y.Entity)))
            {
                previousSelection.Add(childEntity);
            }

            var newSelection = new HashSet <Entity>(e.NewSelection);

            foreach (var childEntity in e.NewSelection.SelectDeep(x => x.Transform.Children.Select(y => y.Entity)))
            {
                newSelection.Add(childEntity);
            }

            previousSelection.ExceptWith(newSelection);

            // Update the selection on the gizmo entities
            foreach (var previousEntity in previousSelection)
            {
                UpdateGizmoEntitiesSelection(previousEntity, isSelected: false);
            }

            foreach (var newEntity in newSelection)
            {
                UpdateGizmoEntitiesSelection(newEntity, isSelected: true);
            }
        }
        private void SelectionUpdated(object sender, [NotNull] EntitySelectionEventArgs e)
        {
            var recursiveSelection = new HashSet <Entity>(e.NewSelection);

            foreach (var childEntity in e.NewSelection.SelectDeep(x => x.Transform.Children.Select(y => y.Entity)))
            {
                recursiveSelection.Add(childEntity);
            }

            editor.Controller.InvokeAsync(() =>
            {
                // update the selection on the gizmo entities.
                selectedEntities.Clear();
                selectedEntities.AddRange(recursiveSelection);
            });
        }
        private void UpdateModifiedEntitiesList(object sender, [NotNull] EntitySelectionEventArgs e)
        {
            EntityWithGizmo = e.NewSelection.LastOrDefault();
            if (ActiveTransformationGizmo != null && EntityWithGizmo == null)
            {
                // Reset the transformation axes if the selection is cleared.
                ActiveTransformationGizmo.ClearTransformationAxes();
            }
            var modifiedEntities = new List <Entity>();

            modifiedEntities.AddRange(e.NewSelection);

            // update the selected entities collections on transformation gizmo
            foreach (var gizmo in transformationGizmos)
            {
                gizmo.AnchorEntity     = EntityWithGizmo;
                gizmo.ModifiedEntities = modifiedEntities;
            }
        }
 private void UpdateModifiedEntitiesList(object sender, EntitySelectionEventArgs e)
 {
     selectedEntity = e.NewSelection.Count == 1 ? e.NewSelection.Single() : null;
 }