Add editor status message about amount of selected actors
This commit is contained in:
@@ -16,6 +16,8 @@ namespace FlaxEditor.Modules
|
||||
/// <seealso cref="FlaxEditor.Modules.EditorModule" />
|
||||
public sealed class SceneEditingModule : EditorModule
|
||||
{
|
||||
private int _lastSelectionStatus = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The selected objects.
|
||||
/// </summary>
|
||||
@@ -193,6 +195,20 @@ namespace FlaxEditor.Modules
|
||||
Undo.AddAction(new SelectionChangeAction(before, Selection.ToArray(), OnSelectionUndo));
|
||||
|
||||
OnSelectionChanged();
|
||||
|
||||
// Display amount of selected actors on the status bar
|
||||
Editor.UI.RemoveStatusMessage(_lastSelectionStatus);
|
||||
var objects = Selection.Count;
|
||||
var actors = CountActors(Selection);
|
||||
_lastSelectionStatus = Editor.UI.AddStatusMessage($"Selected {objects} {(objects > 1 ? "objects" : "object")} (total {actors} {(actors > 1 ? "actors" : "actor")})");
|
||||
}
|
||||
|
||||
private int CountActors(List<SceneGraphNode> nodes)
|
||||
{
|
||||
int result = 0;
|
||||
foreach (var node in nodes)
|
||||
result += 1 + CountActors(node.ChildNodes);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void OnSelectionUndo(SceneGraphNode[] toSelect)
|
||||
|
||||
Reference in New Issue
Block a user