BsScriptResourceManager.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include "BsScriptEnginePrerequisites.h"
  3. #include "CmModule.h"
  4. #include <mono/jit/jit.h>
  5. namespace BansheeEngine
  6. {
  7. class BS_SCR_BE_EXPORT ScriptResourceManager : public Module<ScriptResourceManager>
  8. {
  9. public:
  10. ScriptResourceManager();
  11. /**
  12. * @note Throws an exception if resource for the handle already exists.
  13. * Creates a new managed instance of the object.
  14. */
  15. ScriptTexture2D* createScriptTexture(const HTexture& resourceHandle);
  16. /**
  17. * @note Throws an exception if resource for the handle already exists.
  18. * Initializes the ScriptResource with an existing managed instance.
  19. */
  20. ScriptTexture2D* createScriptTexture(MonoObject* existingInstance, const HTexture& resourceHandle);
  21. /**
  22. * @note Throws an exception if resource for the handle already exists.
  23. * Creates a new managed instance of the object.
  24. */
  25. ScriptSpriteTexture* createScriptSpriteTexture(const HSpriteTexture& resourceHandle);
  26. /**
  27. * @note Throws an exception if resource for the handle already exists.
  28. * Initializes the ScriptResource with an existing managed instance.
  29. */
  30. ScriptSpriteTexture* createScriptSpriteTexture(MonoObject* existingInstance, const HSpriteTexture& resourceHandle);
  31. /**
  32. * @note Returns nullptr if script resource doesn't exist.
  33. */
  34. ScriptTexture2D* getScriptTexture(const HTexture& resourceHandle);
  35. /**
  36. * @note Returns nullptr if script resource doesn't exist.
  37. */
  38. ScriptSpriteTexture* getScriptSpriteTexture(const HSpriteTexture& resourceHandle);
  39. /**
  40. * @note Returns nullptr if script resource doesn't exist.
  41. */
  42. ScriptResource* getScriptResource(const HResource& resourceHandle);
  43. void destroyScriptResource(ScriptResource* resource);
  44. private:
  45. UnorderedMap<String, ScriptResource*>::type mScriptResources;
  46. MonoClass* mTextureClass;
  47. MonoClass* mSpriteTextureClass;
  48. void throwExceptionIfInvalidOrDuplicate(const String& uuid) const;
  49. };
  50. }