ManagedResource.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System.Runtime.CompilerServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Resources
  7. * @{
  8. */
  9. /// <summary>
  10. /// Base class for all user-defined managed resources. Managed resources are automatically serialized, can be saved
  11. /// and persistently referenced by other objects.
  12. /// </summary>
  13. public class ManagedResource : Resource
  14. {
  15. /// <summary>
  16. /// Constructor for internal use by the runtime.
  17. /// </summary>
  18. protected ManagedResource()
  19. { }
  20. /// <summary>
  21. /// Creates a new managed resource.
  22. /// </summary>
  23. /// <typeparam name="T">Type of the managed resource to create.</typeparam>
  24. /// <returns>A new instance of a managed resource with default values.</returns>
  25. static public T Create<T>() where T : ManagedResource, new()
  26. {
  27. T newResource = new T();
  28. Internal_CreateInstance(newResource);
  29. return newResource;
  30. }
  31. [MethodImpl(MethodImplOptions.InternalCall)]
  32. private static extern void Internal_CreateInstance(ManagedResource resource);
  33. }
  34. /** @} */
  35. }