// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using System; using FlaxEditor.Modules; using FlaxEngine; namespace FlaxEditor.Actions { /// /// Change order or enable/disable undo action. /// /// /// [Serializable] class ChangeScriptAction : IUndoAction, ISceneEditAction { [Serialize] private Guid _scriptId; [Serialize] private bool _enableA; [Serialize] private int _orderA; [Serialize] private bool _enableB; [Serialize] private int _orderB; private ChangeScriptAction(Script script, bool enable, int order) { _scriptId = script.ID; _enableA = script.Enabled; _orderA = script.OrderInParent; _enableB = enable; _orderB = order; } /// /// Creates new undo action that changes script order in parent actor scripts collection. /// /// The script to reorder. /// New index. /// The action (not performed yet). public static ChangeScriptAction ChangeOrder(Script script, int newOrder) { return new ChangeScriptAction(script, script.Enabled, newOrder); } /// /// Creates new undo action that enables/disables script. /// /// The script to enable or disable. /// New enable state. /// The action (not performed yet). public static ChangeScriptAction ChangeEnabled(Script script, bool newEnabled) { return new ChangeScriptAction(script, newEnabled, script.OrderInParent); } /// public string ActionString => "Edit script"; /// public void Do() { var script = FlaxEngine.Object.Find