BsSerializedSceneObject.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. namespace bs
  7. {
  8. /** @addtogroup Utility-Editor
  9. * @{
  10. */
  11. /**
  12. * Serializes the current state of a scene object and allows that state to be restored. The advantage of using this
  13. * class versus normal serialization is that the deserialization happens into the original scene object, instead of
  14. * creating a new scene object.
  15. */
  16. class BS_ED_EXPORT BS_SCRIPT_EXPORT(m:Utility-Editor,api:bed) SerializedSceneObject final
  17. {
  18. public:
  19. /**
  20. * Serializes the current state of the provided scene object.
  21. *
  22. * @param[in] sceneObject Object whose state to serialize.
  23. * @param[in] hierarchy If true all children of the provided scene object will be serialized as well,
  24. * otherwise just the provided object will.
  25. */
  26. BS_SCRIPT_EXPORT()
  27. SerializedSceneObject(const HSceneObject& sceneObject, bool hierarchy = false);
  28. ~SerializedSceneObject();
  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. UINT8* mSerializedObject = nullptr;
  41. UINT32 mSerializedObjectSize = 0;
  42. UINT64 mSerializedObjectParentId = 0;
  43. };
  44. /** @} */
  45. }