#pragma once #include "BsScriptEnginePrerequisites.h" #include "BsModule.h" #include namespace BansheeEngine { class BS_SCR_BE_EXPORT ScriptResourceManager : public Module { public: ScriptResourceManager(); /** * @note Throws an exception if resource for the handle already exists. * Creates a new managed instance of the object. */ template void createScriptResource(const ResourceHandle& resourceHandle, RetType** out); /** * @note Throws an exception if resource for the handle already exists. * Initializes the ScriptResource with an existing managed instance. */ template void createScriptResource(MonoObject* existingInstance, const ResourceHandle& resourceHandle, RetType** out); /** * @note If @p create is true, creates a new script resource if one doesn't exist, * otherwise returns nullptr if script resource doesn't exist. */ template void getScriptResource(const ResourceHandle& resourceHandle, RetType** out, bool create = false); template<> void createScriptResource(const ResourceHandle& resourceHandle, ScriptStringTable** out); template<> void createScriptResource(const HResource& resourceHandle, ScriptResourceBase** out); /** * @note Returns nullptr if script resource doesn't exist. */ ScriptResourceBase* getScriptResource(const String& UUID); void destroyScriptResource(ScriptResourceBase* resource); private: UnorderedMap mScriptResources; void throwExceptionIfInvalidOrDuplicate(const String& uuid) const; }; }