BsSerializedSceneObject.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2019 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "Utility/BsEditorUtility.h"
  6. #include "FileSystem/BsDataStream.h"
  7. namespace bs
  8. {
  9. /** @addtogroup Utility-Editor
  10. * @{
  11. */
  12. /**
  13. * Serializes the current state of a scene object and allows that state to be restored. The advantage of using this
  14. * class versus normal serialization is that the deserialization happens into the original scene object, instead of
  15. * creating a new scene object.
  16. */
  17. class BS_ED_EXPORT BS_SCRIPT_EXPORT(m:Utility-Editor,api:bed) SerializedSceneObject final
  18. {
  19. public:
  20. /**
  21. * Serializes the current state of the provided scene object.
  22. *
  23. * @param[in] sceneObject Object whose state to serialize.
  24. * @param[in] hierarchy If true all children of the provided scene object will be serialized as well,
  25. * otherwise just the provided object will.
  26. */
  27. BS_SCRIPT_EXPORT()
  28. SerializedSceneObject(const HSceneObject& sceneObject, bool hierarchy = false);
  29. /**
  30. * Restores the scene object to the state as it was when this object was created. If the scene object was deleted
  31. * since it will be resurrected.
  32. */
  33. BS_SCRIPT_EXPORT()
  34. void restore();
  35. private:
  36. friend class UndoRedo;
  37. HSceneObject mSceneObject;
  38. EditorUtility::SceneObjProxy mSceneObjectProxy;
  39. bool mRecordHierarchy;
  40. SPtr<MemoryDataStream> mSerializedObject;
  41. UINT64 mSerializedObjectParentId = 0;
  42. };
  43. /** @} */
  44. }