BsCmdInstantiateSO.h 1.4 KB

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