SerializedSceneObject.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. using bs;
  6. namespace bs.Editor
  7. {
  8. /** @addtogroup Utility-Editor
  9. * @{
  10. */
  11. /// <summary>
  12. /// Records a state of a scene object, it's components and optionally its child hierarchy. Stored state can
  13. /// be applied to a scene object in order to restore the originally recorded state.
  14. /// </summary>
  15. public class SerializedSceneObject : ScriptObject
  16. {
  17. /// <summary>
  18. /// Records the current state of the provided scene object.
  19. /// </summary>
  20. /// <param name="so">Scene object to record the state for.</param>
  21. /// <param name="hierarchy">If true, state will be recorded for the scene object and all of its children. Otherwise
  22. /// the state will only be recorded for the provided scene object.</param>
  23. public SerializedSceneObject(SceneObject so, bool hierarchy)
  24. {
  25. IntPtr soPtr = IntPtr.Zero;
  26. if (so != null)
  27. soPtr = so.GetCachedPtr();
  28. Internal_CreateInstance(this, soPtr, hierarchy);
  29. }
  30. /// <summary>
  31. /// Restores the referenced scene object to its original state.
  32. /// </summary>
  33. public void Restore()
  34. {
  35. Internal_Restore(mCachedPtr);
  36. }
  37. [MethodImpl(MethodImplOptions.InternalCall)]
  38. private static extern void Internal_CreateInstance(SerializedSceneObject instance, IntPtr so, bool hierarchy);
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern void Internal_Restore(IntPtr thisPtr);
  41. }
  42. /** @} */
  43. }