BsCmdReparentSO.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsEditorCommand.h"
  4. #include "BsUndoRedo.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief A command used for undo/redo purposes. It records a scene object
  9. * parent change operations. It allows you to apply the parent change
  10. * or revert the object to its original parent as needed.
  11. */
  12. class CmdReparentSO : public EditorCommand
  13. {
  14. public:
  15. /**
  16. * @brief Creates and executes the command on the provided scene object.
  17. * Automatically registers the command with undo/redo system.
  18. *
  19. * @param sceneObjects Object(s) to change the parent for.
  20. * @param newParent New parent for the provided objects.
  21. */
  22. static void execute(const Vector<HSceneObject>& sceneObjects, const HSceneObject& newParent);
  23. /**
  24. * @copydoc EditorCommand::commit
  25. */
  26. void commit() override;
  27. /**
  28. * @copydoc EditorCommand::revert
  29. */
  30. void revert() override;
  31. private:
  32. friend class UndoRedo;
  33. CmdReparentSO(const Vector<HSceneObject>& sceneObjects, const HSceneObject& newParent);
  34. Vector<HSceneObject> mSceneObjects;
  35. Vector<HSceneObject> mOldParents;
  36. HSceneObject mNewParent;
  37. };
  38. }