ManagedResource.cs 1.2 KB

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