// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
using FlaxEditor.SceneGraph;
namespace FlaxEditor
{
///
/// Objects selection change action.
///
///
[Serializable]
public class SelectionChangeAction : UndoActionBase
{
///
/// The undo data.
///
[Serializable]
public struct DataStorage
{
///
/// The 'before' selection.
///
public SceneGraphNode[] Before;
///
/// The 'after' selection.
///
public SceneGraphNode[] After;
}
private Action _callback;
///
/// User selection has changed
///
/// Previously selected nodes
/// Newly selected nodes
/// Selection change callback
public SelectionChangeAction(SceneGraphNode[] before, SceneGraphNode[] after, Action callback)
{
Data = new DataStorage
{
Before = before,
After = after,
};
_callback = callback;
}
///
public override string ActionString => "Selection change";
///
public override void Do()
{
var data = Data;
_callback(data.After);
}
///
public override void Undo()
{
var data = Data;
_callback(data.Before);
}
}
}