BsCmdBreakPrefab.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 breaks a prefab link of a scene object
  9. * and allows you to restore link.
  10. */
  11. class BS_ED_EXPORT CmdBreakPrefab : public EditorCommand
  12. {
  13. public:
  14. ~CmdBreakPrefab();
  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 sceneObject Scene object whose prefab link to break.
  20. * @param description Optional description of what exactly the command does.
  21. */
  22. static void execute(const HSceneObject& sceneObject, const WString& description = StringUtil::WBLANK);
  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. CmdBreakPrefab(const WString& description, const HSceneObject& sceneObject);
  34. /**
  35. * @brief Clears all internal cached data. Should be called whenever a change is commited.
  36. */
  37. void clear();
  38. HSceneObject mSceneObject;
  39. HSceneObject mPrefabRoot;
  40. String mPrefabLinkUUID;
  41. PrefabDiffPtr mPrefabDiff;
  42. UnorderedMap<UINT64, UINT32> mLinkIds;
  43. };
  44. }