瀏覽代碼

Reverted Module changes

Marko Pintera 11 年之前
父節點
當前提交
0a242cf23e

+ 5 - 5
BansheeEditor/Source/BsEditorApplication.cpp

@@ -55,7 +55,7 @@ namespace BansheeEditor
 
 		const String& renderSystemLibraryName = getLibraryNameForRenderSystem(renderSystemPlugin);
 		gBansheeApp().startUp(renderWindowDesc, renderSystemLibraryName, "BansheeForwardRenderer"); // TODO - Make renderer and resource cache dir customizable
-		EditorGUI::startUp();
+		EditorGUI::startUp(cm_new<EditorGUI>());
 
 		{
 			auto inputConfig = VirtualInput::instance().getConfiguration();
@@ -69,13 +69,13 @@ namespace BansheeEditor
 			inputConfig->registerButton("Delete", BC_DELETE);
 		}
 
-		ProjectLibrary::startUp(getActiveProjectPath());
+		ProjectLibrary::startUp(cm_new<ProjectLibrary>(getActiveProjectPath()));
 
-		UndoRedo::startUp();
-		EditorWindowManager::startUp();
+		UndoRedo::startUp(cm_new<UndoRedo>());
+		EditorWindowManager::startUp(cm_new<EditorWindowManager>());
 
 		MainEditorWindow* mainWindow = MainEditorWindow::create(gApplication().getPrimaryWindow());
-		EditorWidgetManager::startUp();
+		EditorWidgetManager::startUp(cm_new<EditorWidgetManager>());
 
 		gApplication().loadPlugin("SBansheeEditor"); // Managed part of the editor
 

+ 1 - 1
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -76,7 +76,7 @@ namespace BansheeEditor
 		AABox dbgBox(Vector3(-300, -200, 1000), Vector3(300, 300, 1500));
 		//DrawHelper3D::instance().drawAABox(sceneCamera, dbgBox, Color::Green, 250.0f);
 
-		ProfilerOverlay::startUp(sceneCamera->getViewport());
+		ProfilerOverlay::startUp(cm_new<ProfilerOverlay>(sceneCamera->getViewport()));
 		ProfilerOverlay::instance().show();
 	}
 

+ 1 - 1
BansheeEditorExec/BsEditorExec.cpp

@@ -14,7 +14,7 @@ int CALLBACK WinMain(
 	_In_  int nCmdShow
 	)
 {
-	EditorApplication::startUp(RenderSystemPlugin::DX11);
+	EditorApplication::startUp(cm_new<EditorApplication>(RenderSystemPlugin::DX11));
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::shutDown();
 

+ 0 - 1
BansheeEngine/Include/BsProfilerOverlay.h

@@ -46,7 +46,6 @@ namespace BansheeEngine
 		};
 
 	public:
-		ProfilerOverlay() {} // For Module purposes only
 		ProfilerOverlay(const CM::ViewportPtr& target);
 		~ProfilerOverlay();
 

+ 10 - 10
BansheeEngine/Source/BsApplication.cpp

@@ -40,23 +40,23 @@ namespace BansheeEngine
 		
 		CM::gApplication().startUp(desc);
 
-		VirtualInput::startUp();
-		ScriptManager::startUp();
-		GUIManager::startUp();
-		GUIMaterialManager::startUp();
-		OverlayManager::startUp();
+		VirtualInput::startUp(cm_new<VirtualInput>());
+		ScriptManager::startUp(cm_new<ScriptManager>());
+		GUIManager::startUp(cm_new<GUIManager>());
+		GUIMaterialManager::startUp(cm_new<GUIMaterialManager>());
+		OverlayManager::startUp(cm_new<OverlayManager>());
 
-		BuiltinMaterialManager::startUp();
+		BuiltinMaterialManager::startUp(cm_new<BuiltinMaterialManager>());
 		BuiltinMaterialManager::instance().addFactory(cm_new<D3D9BuiltinMaterialFactory>());
 		BuiltinMaterialManager::instance().addFactory(cm_new<D3D11BuiltinMaterialFactory>());
 		BuiltinMaterialManager::instance().addFactory(cm_new<GLBuiltinMaterialFactory>());
 		BuiltinMaterialManager::instance().setActive(desc.renderSystem);
 
-		DrawHelper2D::startUp();
-		DrawHelper3D::startUp();
+		DrawHelper2D::startUp(cm_new<DrawHelper2D>());
+		DrawHelper3D::startUp(cm_new<DrawHelper3D>());
 
-		BuiltinResources::startUp();
-		Cursor::startUp();
+		BuiltinResources::startUp(cm_new<BuiltinResources>());
+		Cursor::startUp(cm_new<Cursor>());
 
 		CM::gApplication().loadPlugin("BansheeMono", &mMonoPlugin);
 		CM::gApplication().loadPlugin("SBansheeEngine", &mSBansheeEnginePlugin); // Scripting interface

+ 2 - 2
BansheeEngine/Source/BsGUIManager.cpp

@@ -83,10 +83,10 @@ namespace BansheeEngine
 		mInputCaret = cm_new<GUIInputCaret, PoolAlloc>();
 		mInputSelection = cm_new<GUIInputSelection, PoolAlloc>();
 
-		DragAndDropManager::startUp();
+		DragAndDropManager::startUp(cm_new<DragAndDropManager>());
 		mDragEndedConn = DragAndDropManager::instance().onDragEnded.connect(boost::bind(&GUIManager::onMouseDragEnded, this, _1));
 
-		GUIDropDownBoxManager::startUp();
+		GUIDropDownBoxManager::startUp(cm_new<GUIDropDownBoxManager>());
 
 		mVertexDesc = cm_shared_ptr<VertexDataDesc>();
 		mVertexDesc->addVertElem(VET_FLOAT2, VES_POSITION);

+ 1 - 1
BansheeMono/Source/BsMonoScriptManager.cpp

@@ -19,7 +19,7 @@ namespace BansheeEngine
 
 	void MonoScriptSystem::initialize()
 	{
-		MonoManager::startUp();
+		MonoManager::startUp(cm_new<MonoManager>());
 		mIsInitialized = true;
 	}
 }

+ 1 - 1
BansheeOctreeSM/Source/BsSceneManagerPlugin.cpp

@@ -13,7 +13,7 @@ namespace BansheeEngine
 
 	extern "C" BS_SM_EXPORT void* loadPlugin()
 	{
-		SceneManager::startUp<OctreeSceneManager>();
+		SceneManager::startUp(cm_new<OctreeSceneManager>());
 
 		return nullptr;
 	}

+ 1 - 1
CamelotCore/Include/CmGpuProgramManager.h

@@ -42,7 +42,7 @@ namespace CamelotFramework {
 	/** \addtogroup Resources
 	*  @{
 	*/
-	class CM_EXPORT GpuProgramManager : public Module<GpuProgramManager, true>
+	class CM_EXPORT GpuProgramManager : public Module<GpuProgramManager>
 	{
 	public:
 

+ 1 - 1
CamelotCore/Include/CmHardwareBufferManager.h

@@ -46,7 +46,7 @@ namespace CamelotFramework {
 
 	/** Base definition of a hardware buffer manager.
 	*/
-	class CM_EXPORT HardwareBufferManager : public Module<HardwareBufferManager, true>
+	class CM_EXPORT HardwareBufferManager : public Module<HardwareBufferManager>
 	{
     public:
         HardwareBufferManager();

+ 1 - 1
CamelotCore/Include/CmQueryManager.h

@@ -11,7 +11,7 @@ namespace CamelotFramework
 	 * 			
 	 * @note	Core thread only.
 	 */
-	class CM_EXPORT QueryManager : public Module<QueryManager, true>
+	class CM_EXPORT QueryManager : public Module<QueryManager>
 	{
 	public:
 		QueryManager();

+ 1 - 1
CamelotCore/Include/CmRenderStateManager.h

@@ -5,7 +5,7 @@
 
 namespace CamelotFramework
 {
-	class CM_EXPORT RenderStateManager : public Module<RenderStateManager, true>
+	class CM_EXPORT RenderStateManager : public Module<RenderStateManager>
 	{
 	public:
 		/**

+ 1 - 1
CamelotCore/Include/CmRenderSystem.h

@@ -78,7 +78,7 @@ namespace CamelotFramework
 	@version
 	1.0
 	*/
-	class CM_EXPORT RenderSystem : public Module<RenderSystem, true>
+	class CM_EXPORT RenderSystem : public Module<RenderSystem>
 	{
 	public:
 		/** Default Constructor.

+ 1 - 1
CamelotCore/Include/CmRenderWindowManager.h

@@ -7,7 +7,7 @@
 
 namespace CamelotFramework
 {
-	class CM_EXPORT RenderWindowManager : public Module<RenderWindowManager, true>
+	class CM_EXPORT RenderWindowManager : public Module<RenderWindowManager>
 	{
 	public:
 		RenderWindowManager();

+ 1 - 1
CamelotCore/Include/CmSceneManager.h

@@ -12,7 +12,7 @@ namespace CamelotFramework
 	 * 			query functionality. You should override it with your own version that
 	 * 			implements a spatial data structure of your choice for faster queries.
 	 */
-	class CM_EXPORT SceneManager : public Module<SceneManager, true>
+	class CM_EXPORT SceneManager : public Module<SceneManager>
 	{
 	public:
 		SceneManager();

+ 1 - 1
CamelotCore/Include/CmTextureManager.h

@@ -39,7 +39,7 @@ namespace CamelotFramework
      *
      * @note	Must be initialized when RenderSystem is first started.
      */
-    class CM_EXPORT TextureManager : public Module<TextureManager, true>
+    class CM_EXPORT TextureManager : public Module<TextureManager>
     {
     public:
 

+ 18 - 18
CamelotCore/Source/CmApplication.cpp

@@ -53,23 +53,23 @@ namespace CamelotFramework
 		Platform::startUp();
 		MemStack::beginThread();
 
-		Profiler::startUp();
-		StringTable::startUp();
-		DeferredCallManager::startUp();
-		Time::startUp();
-		DynLibManager::startUp();
-		CoreGpuObjectManager::startUp();
-		GameObjectManager::startUp();
-		Resources::startUp();
-		HighLevelGpuProgramManager::startUp();
-
-		CoreThread::startUp();
-		RenderSystemManager::startUp();
+		Profiler::startUp(cm_new<Profiler>());
+		StringTable::startUp(cm_new<StringTable>());
+		DeferredCallManager::startUp(cm_new<DeferredCallManager>());
+		Time::startUp(cm_new<Time>());
+		DynLibManager::startUp(cm_new<DynLibManager>());
+		CoreGpuObjectManager::startUp(cm_new<CoreGpuObjectManager>());
+		GameObjectManager::startUp(cm_new<GameObjectManager>());
+		Resources::startUp(cm_new<Resources>());
+		HighLevelGpuProgramManager::startUp(cm_new<HighLevelGpuProgramManager>());
+
+		CoreThread::startUp(cm_new<CoreThread>());
+		RenderSystemManager::startUp(cm_new<RenderSystemManager>());
 
 		mPrimaryWindow = RenderSystemManager::instance().initialize(desc.renderSystem, desc.primaryWindowDesc);
 
-		Input::startUp();
-		RendererManager::startUp();
+		Input::startUp(cm_new<Input>());
+		RendererManager::startUp(cm_new<RendererManager>());
 
 		loadPlugin(desc.renderer);
 		RendererManager::instance().setActive(desc.renderer);
@@ -79,11 +79,11 @@ namespace CamelotFramework
 
 		loadPlugin(desc.sceneManager, &mSceneManagerPlugin);
 
-		MeshManager::startUp();
-		MaterialManager::startUp();
-		FontManager::startUp();
+		MeshManager::startUp(cm_new<MeshManager>());
+		MaterialManager::startUp(cm_new<MaterialManager>());
+		FontManager::startUp(cm_new<FontManager>());
 
-		Importer::startUp();
+		Importer::startUp(cm_new<Importer>());
 
 		for(auto& importerName : desc.importers)
 			loadPlugin(importerName);

+ 7 - 7
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp

@@ -104,22 +104,22 @@ namespace CamelotFramework
 		}
 
 		// Create the texture manager for use by others		
-		TextureManager::startUp<D3D11TextureManager>();
+		TextureManager::startUp(cm_new<D3D11TextureManager>());
 
 		// Also create hardware buffer manager		
-		HardwareBufferManager::startUp<D3D11HardwareBufferManager>(std::ref(*mDevice));
+		HardwareBufferManager::startUp(cm_new<D3D11HardwareBufferManager>(std::ref(*mDevice)));
 
 		// Create the GPU program manager		
-		GpuProgramManager::startUp<D3D11GpuProgramManager>(std::ref(*mDevice));
+		GpuProgramManager::startUp(cm_new<D3D11GpuProgramManager>(std::ref(*mDevice)));
 
 		// Create render window manager
-		RenderWindowManager::startUp<D3D11RenderWindowManager>(this);
+		RenderWindowManager::startUp(cm_new<D3D11RenderWindowManager>(this));
 
 		// Create & register HLSL factory		
 		mHLSLFactory = cm_new<D3D11HLSLProgramFactory>();
 
 		// Create render state manager
-		RenderStateManager::startUp<D3D11RenderStateManager>();
+		RenderStateManager::startUp(cm_new<D3D11RenderStateManager>());
 
 		mCurrentCapabilities = createRenderSystemCapabilities();
 
@@ -130,9 +130,9 @@ namespace CamelotFramework
 
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
 
-		D3D11RenderUtility::startUp(mDevice);
+		D3D11RenderUtility::startUp(cm_new<D3D11RenderUtility>(mDevice));
 
-		QueryManager::startUp<D3D11QueryManager>();
+		QueryManager::startUp(cm_new<D3D11QueryManager>());
 
 		RenderSystem::initialize_internal(asyncOp);
 

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystemFactory.cpp

@@ -5,7 +5,7 @@ namespace CamelotFramework
 {
 	void D3D11RenderSystemFactory::create()
 	{
-		RenderSystem::startUp<D3D11RenderSystem>();
+		RenderSystem::startUp(cm_new<D3D11RenderSystem>());
 	}
 
 	D3D11RenderSystemFactory::InitOnStart D3D11RenderSystemFactory::initOnStart;

+ 6 - 6
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -151,10 +151,10 @@ namespace CamelotFramework
 		mDeviceManager = cm_new<D3D9DeviceManager>();
 
 		// Also create hardware buffer manager		
-		HardwareBufferManager::startUp<D3D9HardwareBufferManager>();
+		HardwareBufferManager::startUp(cm_new<D3D9HardwareBufferManager>());
 
 		// Create the GPU program manager		
-		GpuProgramManager::startUp<D3D9GpuProgramManager>();
+		GpuProgramManager::startUp(cm_new<D3D9GpuProgramManager>());
 
 		// Create & register HLSL factory		
 		mHLSLProgramFactory = cm_new<D3D9HLSLProgramFactory>();
@@ -163,10 +163,10 @@ namespace CamelotFramework
 		mCgProgramFactory = cm_new<CgProgramFactory>();
 
 		// Create render window manager
-		RenderWindowManager::startUp<D3D9RenderWindowManager>(this);
+		RenderWindowManager::startUp(cm_new<D3D9RenderWindowManager>(this));
 
 		// Create render state manager
-		RenderStateManager::startUp<RenderStateManager>();
+		RenderStateManager::startUp(cm_new<RenderStateManager>());
 
 		// Create primary window and finalize initialization
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
@@ -174,9 +174,9 @@ namespace CamelotFramework
 		updateRenderSystemCapabilities(d3d9renderWindow);
 
 		// Create the texture manager for use by others		
-		TextureManager::startUp<D3D9TextureManager>();
+		TextureManager::startUp(cm_new<D3D9TextureManager>());
 
-		QueryManager::startUp<D3D9QueryManager>();
+		QueryManager::startUp(cm_new<D3D9QueryManager>());
 
 		// call superclass method
 		RenderSystem::initialize_internal(asyncOp);

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderSystemFactory.cpp

@@ -11,7 +11,7 @@ namespace CamelotFramework
 		HINSTANCE hInst = GetModuleHandle( "CamelotD3D9RenderSystem.dll" );
 	#endif
 
-		RenderSystem::startUp<D3D9RenderSystem>(hInst);
+		RenderSystem::startUp(cm_new<D3D9RenderSystem>(hInst));
 	}
 
 	D3D9RenderSystemFactory::InitOnStart D3D9RenderSystemFactory::initOnStart;

+ 7 - 7
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -137,11 +137,11 @@ namespace CamelotFramework
 		THROW_IF_NOT_CORE_THREAD;
 
 		mGLSupport->start();
-		RenderWindowManager::startUp<GLRenderWindowManager>(this);
+		RenderWindowManager::startUp(cm_new<GLRenderWindowManager>(this));
 
-		RenderStateManager::startUp<RenderStateManager>();
+		RenderStateManager::startUp(cm_new<RenderStateManager>());
 
-		QueryManager::startUp<GLQueryManager>();
+		QueryManager::startUp(cm_new<GLQueryManager>());
 
 		// Initialize a window so we have something to create a GL context with
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
@@ -1800,11 +1800,11 @@ namespace CamelotFramework
 			glUnmapBufferARB = glUnmapBuffer;
 		}
 
-		HardwareBufferManager::startUp<GLHardwareBufferManager>();
+		HardwareBufferManager::startUp(cm_new<GLHardwareBufferManager>());
 		checkForErrors();
 
 		// GPU Program Manager setup
-		GpuProgramManager::startUp<GLGpuProgramManager>();
+		GpuProgramManager::startUp(cm_new<GLGpuProgramManager>());
 		checkForErrors();
 
 		if(caps->isShaderProfileSupported("glsl"))
@@ -1850,7 +1850,7 @@ namespace CamelotFramework
 			if(caps->hasCapability(RSC_HWRENDER_TO_TEXTURE))
 			{
 				// Create FBO manager
-				GLRTTManager::startUp();
+				GLRTTManager::startUp(cm_new<GLRTTManager>());
 				checkForErrors();
 			}
 		}
@@ -1899,7 +1899,7 @@ namespace CamelotFramework
 			CM_EXCEPT(InternalErrorException, "Number of combined uniform block buffers less than the number of individual per-stage buffers!?");
 
 		/// Create the texture manager   
-		TextureManager::startUp<GLTextureManager>(std::ref(*mGLSupport)); 
+		TextureManager::startUp(cm_new<GLTextureManager>(std::ref(*mGLSupport))); 
 		checkForErrors();
 	}
 

+ 1 - 1
CamelotGLRenderer/Source/CmGLRenderSystemFactory.cpp

@@ -5,7 +5,7 @@ namespace CamelotFramework
 {
 	void GLRenderSystemFactory::create()
 	{
-		RenderSystem::startUp<GLRenderSystem>();
+		RenderSystem::startUp(cm_new<GLRenderSystem>());
 	}
 
 	GLRenderSystemFactory::InitOnStart GLRenderSystemFactory::initOnStart;

+ 9 - 163
CamelotUtility/Include/CmModule.h

@@ -5,130 +5,13 @@
 
 namespace CamelotFramework
 {
-	template <class T, bool abstract = false>
-	class Module
-	{
-		public:
-		static T& instance()
-		{
-			if(isShutDown)
-			{
-				CM_EXCEPT(InternalErrorException, 
-					"Trying to access a module but it hasn't been started up yet.");
-			}
-
-			if(isDestroyed)
-			{
-				CM_EXCEPT(InternalErrorException, 
-					"Trying to access a destroyed module.");
-			}
-
-			return *_instance;
-		}
-
-		static T* instancePtr()
-		{
-			if(isShutDown)
-			{
-				CM_EXCEPT(InternalErrorException, 
-					"Trying to access a module but it hasn't been started up yet.");
-			}
-
-			if(isDestroyed)
-			{
-				CM_EXCEPT(InternalErrorException, 
-					"Trying to access a destroyed module.");
-			}
-
-			return _instance;
-		}
-		
-#define MAKE_CM_NEW(z, n, unused)																	\
-		template<BOOST_PP_ENUM_PARAMS(n, class T)>													\
-		static void startUp(BOOST_PP_ENUM_BINARY_PARAMS(n, T, &&t) )								\
-		{																							\
-			if(!isShutDown)																			\
-				CM_EXCEPT(InternalErrorException, "Trying to start an already started module.");	\
-																									\
-			_instance = cm_new<T>(std::forward<T0>(t0) BOOST_PP_REPEAT_FROM_TO(1, n, FORWARD_T, ~)); \
-			isShutDown = false;																		\
-																									\
-			((Module*)_instance)->onStartUp();														\
-		}
-
-#define FORWARD_T(z, i, unused) \
-	, std::forward<BOOST_PP_CAT(T, i)>(BOOST_PP_CAT(t, i))
-
-		BOOST_PP_REPEAT_FROM_TO(1, 15, MAKE_CM_NEW, ~)
-
-#undef FORWARD_T
-#undef MAKE_CM_NEW
-
-		static void startUp()
-		{
-			if(!isShutDown)
-				CM_EXCEPT(InternalErrorException, "Trying to start an already started module.");
-
-			_instance = cm_new<T>();
-			isShutDown = false;
-
-			((Module*)_instance)->onStartUp();
-		}
-
-		/**
-		 * @brief	Shuts down this module and frees any resources it is using.
-		 */
-		static void shutDown()
-		{
-			if(isShutDown)
-			{
-				CM_EXCEPT(InternalErrorException, 
-					"Trying to shut down an already shut down module.");
-			}
-
-			((Module*)_instance)->onShutDown();
-
-			cm_delete(_instance);
-			isShutDown = true;
-		}
-
-		/**
-		 * @brief	Query if this object has been started.
-		 */
-		static bool isStarted()
-		{
-			return !isShutDown && !isDestroyed;
-		}
-
-	protected:
-		Module() 
-		{ 
-		}
-
-		virtual ~Module()
-		{ 
-			_instance = nullptr;
-			isDestroyed = true;
-		}
-
-		Module(const Module&) { }
-		Module& operator=(const Module&) { return *this; }
-
-		virtual void onStartUp() {}
-		virtual void onShutDown() {}
-
-		static T* _instance;
-		static bool isShutDown;
-		static bool isDestroyed;
-	};
-
 	/**
 	 * @brief	Represents one engine module. Essentially it is a specialized type of singleton.
 	 */
 	template <class T>
-	class Module<T, true>
+	class Module
 	{
-	public:
+		public:
 		static T& instance()
 		{
 			if(isShutDown)
@@ -162,41 +45,13 @@ namespace CamelotFramework
 
 			return _instance;
 		}
-
-#define MAKE_CM_NEW(z, n, unused)																		\
-		template<class Type BOOST_PP_ENUM_TRAILING_PARAMS(n, class T)>									\
-		static void startUp(BOOST_PP_ENUM_BINARY_PARAMS(n, T, &&t) )									\
-		{																								\
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<T, Type>::value),								\
-				"Invalid type. Specific type must be a child of the type Module is defined with.");		\
-																										\
-			if(!isShutDown)																				\
-				CM_EXCEPT(InternalErrorException, "Trying to start an already started module.");		\
-																										\
-			_instance = cm_new<Type>(std::forward<T0>(t0) BOOST_PP_REPEAT_FROM_TO(1, n, FORWARD_T, ~));	\
-			isShutDown = false;																			\
-																										\
-			((Module*)_instance)->onStartUp();															\
-		}
-
-#define FORWARD_T(z, i, unused) \
-	, std::forward<BOOST_PP_CAT(T, i)>(BOOST_PP_CAT(t, i))
-
-			BOOST_PP_REPEAT_FROM_TO(1, 15, MAKE_CM_NEW, ~)
-
-#undef FORWARD_T
-#undef MAKE_CM_NEW
-
-		template<class Type>
-		static void startUp()
+		
+		static void startUp(T* inst)
 		{
-			BOOST_STATIC_ASSERT_MSG((boost::is_base_of<T, Type>::value), 
-				"Invalid type. Specific type must be a child of the type Module is defined with.");
-
 			if(!isShutDown)
 				CM_EXCEPT(InternalErrorException, "Trying to start an already started module.");
 
-			_instance = cm_new<Type>();
+			_instance = inst;
 			isShutDown = false;
 
 			((Module*)_instance)->onStartUp();
@@ -248,22 +103,13 @@ namespace CamelotFramework
 		static bool isShutDown;
 		static bool isDestroyed;
 	};
-
-	template <class T, bool abstract>
-	T* Module<T, abstract>::_instance = nullptr;
-
-	template <class T, bool abstract>
-	bool Module<T, abstract>::isShutDown = true;
-
-	template <class T, bool abstract>
-	bool Module<T, abstract>::isDestroyed = false;
-
+	
 	template <class T>
-	T* Module<T, true>::_instance = nullptr;
+	T* Module<T>::_instance = nullptr;
 
 	template <class T>
-	bool Module<T, true>::isShutDown = true;
+	bool Module<T>::isShutDown = true;
 
 	template <class T>
-	bool Module<T, true>::isDestroyed = false;
+	bool Module<T>::isDestroyed = false;
 }

+ 3 - 3
SBansheeEngine/Source/BsScriptEnginePlugin.cpp

@@ -50,9 +50,9 @@ namespace BansheeEngine
 		mono_add_internal_call("BansheeEngine.Program::dbgTestComponentClone", &dbgTestComponentClone);
 		mono_add_internal_call("BansheeEngine.Program::reportDbgValue", &reportDbgValue);
 
-		RuntimeScriptObjects::startUp();
-		ScriptResourceManager::startUp();
-		ScriptGameObjectManager::startUp();
+		RuntimeScriptObjects::startUp(cm_new<RuntimeScriptObjects>());
+		ScriptResourceManager::startUp(cm_new<ScriptResourceManager>());
+		ScriptGameObjectManager::startUp(cm_new<ScriptGameObjectManager>());
 
 		RuntimeScriptObjects::instance().refreshScriptObjects(BansheeEngineAssemblyName);