// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. using System.Collections.Generic; using System.Linq; using FlaxEditor.CustomEditors; using FlaxEngine.GUI; namespace FlaxEditor.Windows { /// /// Window used to present collection of selected object(s) properties in a grid. Supports Undo/Redo operations. /// /// /// public class PropertiesWindow : SceneEditorWindow { private IEnumerable undoRecordObjects; /// /// The editor. /// public readonly CustomEditorPresenter Presenter; /// /// Initializes a new instance of the class. /// /// The editor. public PropertiesWindow(Editor editor) : base(editor, true, ScrollBars.Vertical) { Title = "Properties"; Presenter = new CustomEditorPresenter(editor.Undo); Presenter.Panel.Parent = this; Presenter.GetUndoObjects += GetUndoObjects; Presenter.CacheExpandedGroups = true; Editor.SceneEditing.SelectionChanged += OnSelectionChanged; } private IEnumerable GetUndoObjects(CustomEditorPresenter customEditorPresenter) { return undoRecordObjects; } private void OnSelectionChanged() { // Update selected objects // TODO: use cached collection for less memory allocations undoRecordObjects = Editor.SceneEditing.Selection.ConvertAll(x => x.UndoRecordObject).Distinct(); var objects = Editor.SceneEditing.Selection.ConvertAll(x => x.EditableObject).Distinct(); Presenter.Select(objects); } } }