BsCmdInstantiateSO.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsEditorCommand.h"
  4. #include "BsUndoRedo.h"
  5. #include "BsCmdUtility.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief A command used for undo/redo purposes. Instantiates scene object(s)
  10. * from a prefab and removes them as an undo operation.
  11. */
  12. class BS_ED_EXPORT CmdInstantiateSO : public EditorCommand
  13. {
  14. public:
  15. ~CmdInstantiateSO();
  16. /**
  17. * @brief Instantiates the specified prefab.
  18. * Automatically registers the command with undo/redo system.
  19. *
  20. * @param prefab Prefab to instantiate.
  21. * @param description Optional description of what exactly the command does.
  22. *
  23. * @return Instantiated object.
  24. */
  25. static HSceneObject execute(const HPrefab& prefab, const WString& description = StringUtil::WBLANK);
  26. /**
  27. * @copydoc EditorCommand::commit
  28. */
  29. void commit() override;
  30. /**
  31. * @copydoc EditorCommand::revert
  32. */
  33. void revert() override;
  34. private:
  35. friend class UndoRedo;
  36. CmdInstantiateSO(const WString& description, const HPrefab& prefab);
  37. HPrefab mPrefab;
  38. HSceneObject mSceneObject;
  39. };
  40. }