Resources.cs 885 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. public static class Resources
  6. {
  7. public static T Load<T>(string path) where T : Resource
  8. {
  9. return (T)Internal_Load(path);
  10. }
  11. public static void Unload(Resource resource)
  12. {
  13. if (resource != null)
  14. Internal_Unload(resource.GetCachedPtr());
  15. }
  16. public static void UnloadUnused()
  17. {
  18. Internal_UnloadUnused();
  19. }
  20. [MethodImpl(MethodImplOptions.InternalCall)]
  21. private static extern Resource Internal_Load(string path);
  22. [MethodImpl(MethodImplOptions.InternalCall)]
  23. private static extern void Internal_Unload(IntPtr resourcePtr);
  24. [MethodImpl(MethodImplOptions.InternalCall)]
  25. private static extern void Internal_UnloadUnused();
  26. }
  27. }