Browse Source

Modified managed assembly loading so it's possible to reload it on project reload
Loading manage assemblies now attempts to load non-builtin assemblies as well

Marko Pintera 10 years ago
parent
commit
e1eaa8bfe2
36 changed files with 1434 additions and 1347 deletions
  1. 0 8
      BansheeCore/Include/BsCoreApplication.h
  2. 1 13
      BansheeCore/Source/BsCoreApplication.cpp
  3. 5 0
      BansheeEditor/Include/BsEditorApplication.h
  4. 15 5
      BansheeEditor/Source/BsEditorApplication.cpp
  5. 1 0
      BansheeEngine.sln
  6. 10 0
      BansheeEngine/Include/BsApplication.h
  7. 25 12
      BansheeEngine/Include/BsScriptManager.h
  8. 23 18
      BansheeEngine/Source/BsApplication.cpp
  9. 13 7
      BansheeEngine/Source/BsScriptManager.cpp
  10. 0 2
      BansheeMono/BansheeMono.vcxproj
  11. 0 6
      BansheeMono/BansheeMono.vcxproj.filters
  12. 0 31
      BansheeMono/Include/BsMonoScriptManager.h
  13. 1 1
      BansheeMono/Source/BsMonoManager.cpp
  14. 0 9
      BansheeMono/Source/BsMonoPlugin.cpp
  15. 0 32
      BansheeMono/Source/BsMonoScriptManager.cpp
  16. 557 544
      BansheeSL/BsLexerFX.c
  17. 1 1
      BansheeSL/BsLexerFX.h
  18. 501 521
      BansheeSL/BsParserFX.c
  19. 58 57
      BansheeSL/BsParserFX.h
  20. 0 1
      MBansheeEditor/ProjectWindow.cs
  21. 30 0
      SBansheeEditor/Include/BsEditorScriptLibrary.h
  22. 2 0
      SBansheeEditor/SBansheeEditor.vcxproj
  23. 6 0
      SBansheeEditor/SBansheeEditor.vcxproj.filters
  24. 49 0
      SBansheeEditor/Source/BsEditorScriptLibrary.cpp
  25. 2 3
      SBansheeEditor/Source/BsEditorScriptManager.cpp
  26. 4 11
      SBansheeEditor/Source/BsScriptEditorPlugin.cpp
  27. 30 0
      SBansheeEngine/Include/BsEngineScriptLibrary.h
  28. 2 3
      SBansheeEngine/Include/BsScriptAssemblyManager.h
  29. 8 4
      SBansheeEngine/Include/BsScriptObjectManager.h
  30. 2 0
      SBansheeEngine/SBansheeEngine.vcxproj
  31. 6 0
      SBansheeEngine/SBansheeEngine.vcxproj.filters
  32. 67 0
      SBansheeEngine/Source/BsEngineScriptLibrary.cpp
  33. 2 8
      SBansheeEngine/Source/BsScriptAssemblyManager.cpp
  34. 4 45
      SBansheeEngine/Source/BsScriptEnginePlugin.cpp
  35. 9 3
      SBansheeEngine/Source/BsScriptObjectManager.cpp
  36. 0 2
      TODO.txt

+ 0 - 8
BansheeCore/Include/BsCoreApplication.h

@@ -78,14 +78,6 @@ namespace BansheeEngine
 			 */
 			 */
 			void unloadPlugin(DynLib* library);
 			void unloadPlugin(DynLib* library);
 
 
-			/**
-			 * @brief	Calls the shutdown method on the plugin.
-			 *
-			 * @note	This is separate from "unload" method and should be called
-			 *			before unload.
-			 */
-			void shutdownPlugin(DynLib* library);
-
 	protected:
 	protected:
 		/**
 		/**
 		 * @copydoc	Module::onStartUp
 		 * @copydoc	Module::onStartUp

+ 1 - 13
BansheeCore/Source/BsCoreApplication.cpp

@@ -84,7 +84,6 @@ namespace BansheeEngine
 		RenderStateManager::shutDown();
 		RenderStateManager::shutDown();
 
 
 		RendererManager::shutDown();
 		RendererManager::shutDown();
-		shutdownPlugin(mRendererPlugin);
 
 
 		// All CoreObject related modules should be shut down now. They have likely queued CoreObjects for destruction, so
 		// All CoreObject related modules should be shut down now. They have likely queued CoreObjects for destruction, so
 		// we need to wait for those objects to get destroyed before continuing.
 		// we need to wait for those objects to get destroyed before continuing.
@@ -350,19 +349,8 @@ namespace BansheeEngine
 		if(unloadPluginFunc != nullptr)
 		if(unloadPluginFunc != nullptr)
 			unloadPluginFunc();
 			unloadPluginFunc();
 
 
-		gDynLibManager().unload(library);
-	}
-
-	void CoreApplication::shutdownPlugin(DynLib* library)
-	{
-		typedef void(*ShutdownPluginFunc)();
-
-		ShutdownPluginFunc shutdownPluginFunc = (ShutdownPluginFunc)library->getSymbol("shutdownPlugin");
-
-		if (shutdownPluginFunc != nullptr)
-			shutdownPluginFunc();
-
 		mPluginUpdateFunctions.erase(library);
 		mPluginUpdateFunctions.erase(library);
+		gDynLibManager().unload(library);
 	}
 	}
 
 
 	ShaderIncludeHandlerPtr CoreApplication::getShaderIncludeHandler() const
 	ShaderIncludeHandlerPtr CoreApplication::getShaderIncludeHandler() const

+ 5 - 0
BansheeEditor/Include/BsEditorApplication.h

@@ -113,6 +113,11 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual void postUpdate() override;
 		virtual void postUpdate() override;
 
 
+		/**
+		 * @copydoc	Application::loadScriptSystem
+		 */
+		void loadScriptSystem() override;
+
 		/**
 		/**
 		 * @brief	Loads the previously saved editor widget layout from the default location.
 		 * @brief	Loads the previously saved editor widget layout from the default location.
 		 *			Can return null if no layout was previously saved.
 		 *			Can return null if no layout was previously saved.

+ 15 - 5
BansheeEditor/Source/BsEditorApplication.cpp

@@ -21,6 +21,7 @@
 #include "BsProjectLibrary.h"
 #include "BsProjectLibrary.h"
 #include "BsProjectSettings.h"
 #include "BsProjectSettings.h"
 #include "BsEditorSettings.h"
 #include "BsEditorSettings.h"
+#include "BsScriptManager.h"
 
 
 // DEBUG ONLY
 // DEBUG ONLY
 #include "BsResources.h"
 #include "BsResources.h"
@@ -65,7 +66,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	EditorApplication::EditorApplication(RenderAPIPlugin renderAPIPlugin)
 	EditorApplication::EditorApplication(RenderAPIPlugin renderAPIPlugin)
-		:Application(createRenderWindowDesc(), renderAPIPlugin, RendererPlugin::Default), 
+		:Application(createRenderWindowDesc(), renderAPIPlugin, RendererPlugin::Default),
 		mActiveRAPIPlugin(renderAPIPlugin), mSBansheeEditorPlugin(nullptr), mIsProjectLoaded(false)
 		mActiveRAPIPlugin(renderAPIPlugin), mSBansheeEditorPlugin(nullptr), mIsProjectLoaded(false)
 	{
 	{
 
 
@@ -73,8 +74,6 @@ namespace BansheeEngine
 
 
 	EditorApplication::~EditorApplication()
 	EditorApplication::~EditorApplication()
 	{
 	{
-		shutdownPlugin(mSBansheeEditorPlugin);
-
 		/************************************************************************/
 		/************************************************************************/
 		/* 								DEBUG CODE                      		*/
 		/* 								DEBUG CODE                      		*/
 		/************************************************************************/
 		/************************************************************************/
@@ -142,7 +141,6 @@ namespace BansheeEngine
 		CodeEditorManager::startUp();
 		CodeEditorManager::startUp();
 
 
 		MainEditorWindow* mainWindow = MainEditorWindow::create(getPrimaryWindow());
 		MainEditorWindow* mainWindow = MainEditorWindow::create(getPrimaryWindow());
-		loadPlugin("SBansheeEditor", &mSBansheeEditorPlugin); // Managed part of the editor
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								DEBUG CODE                      		*/
 		/* 								DEBUG CODE                      		*/
@@ -157,7 +155,7 @@ namespace BansheeEngine
 		HRenderable testRenderable = testModelGO->addComponent<Renderable>();
 		HRenderable testRenderable = testModelGO->addComponent<Renderable>();
 
 
 		Path testShaderLoc = RUNTIME_DATA_PATH + L"Test.bsl";;
 		Path testShaderLoc = RUNTIME_DATA_PATH + L"Test.bsl";;
-		
+
 		mTestShader = Importer::instance().import<Shader>(testShaderLoc);
 		mTestShader = Importer::instance().import<Shader>(testShaderLoc);
 
 
 		gResources().save(mTestShader, L"C:\\testShader.asset", true);
 		gResources().save(mTestShader, L"C:\\testShader.asset", true);
@@ -224,6 +222,13 @@ namespace BansheeEngine
 		Application::onShutDown();
 		Application::onShutDown();
 	}
 	}
 
 
+	void EditorApplication::loadScriptSystem()
+	{
+		Application::loadScriptSystem();
+
+		loadPlugin("SBansheeEditor", &mSBansheeEditorPlugin); // Managed part of the editor
+	}
+
 	void EditorApplication::startUp(RenderAPIPlugin renderAPI)
 	void EditorApplication::startUp(RenderAPIPlugin renderAPI)
 	{
 	{
 		CoreApplication::startUp<EditorApplication>(renderAPI);
 		CoreApplication::startUp<EditorApplication>(renderAPI);
@@ -263,6 +268,9 @@ namespace BansheeEngine
 
 
 	Path EditorApplication::getScriptAssemblyFolder() const
 	Path EditorApplication::getScriptAssemblyFolder() const
 	{
 	{
+		if (!isProjectLoaded())
+			return Path::BLANK;
+
 		Path assemblyFolder = getProjectPath();
 		Path assemblyFolder = getProjectPath();
 		assemblyFolder.append(INTERNAL_ASSEMBLY_PATH);
 		assemblyFolder.append(INTERNAL_ASSEMBLY_PATH);
 
 
@@ -304,6 +312,8 @@ namespace BansheeEngine
 		EditorWidgetLayoutPtr layout = loadWidgetLayout();
 		EditorWidgetLayoutPtr layout = loadWidgetLayout();
 		if (layout != nullptr)
 		if (layout != nullptr)
 			EditorWidgetManager::instance().setLayout(layout);
 			EditorWidgetManager::instance().setLayout(layout);
+
+		ScriptManager::instance().reload();
 	}
 	}
 
 
 	bool EditorApplication::isValidProjectPath(const Path& path)
 	bool EditorApplication::isValidProjectPath(const Path& path)

+ 1 - 0
BansheeEngine.sln

@@ -150,6 +150,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenderBeast", "RenderBeast\
 	ProjectSection(ProjectDependencies) = postProject
 	ProjectSection(ProjectDependencies) = postProject
 		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
 		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582} = {CC7F9445-71C9-4559-9976-FF0A64DCB582}
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582} = {CC7F9445-71C9-4559-9976-FF0A64DCB582}
+		{07B0C186-5173-46F2-BE26-7E4148BD0CCA} = {07B0C186-5173-46F2-BE26-7E4148BD0CCA}
 	EndProjectSection
 	EndProjectSection
 EndProject
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BansheeD3D9RenderAPI", "BansheeD3D9RenderAPI\BansheeD3D9RenderAPI.vcxproj", "{796B6DFF-BA04-42B7-A43A-2B14D707A33A}"
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BansheeD3D9RenderAPI", "BansheeD3D9RenderAPI\BansheeD3D9RenderAPI.vcxproj", "{796B6DFF-BA04-42B7-A43A-2B14D707A33A}"

+ 10 - 0
BansheeEngine/Include/BsApplication.h

@@ -90,6 +90,16 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual void postUpdate() override;
 		virtual void postUpdate() override;
 
 
+		/**
+		 * @brief	Loads the script system and all script libraries.
+		 */
+		virtual void loadScriptSystem();
+
+		/**
+		 * @brief	Unloads script libraries and shuts down the script system.
+		 */
+		virtual void unloadScriptSystem();
+
 	private:
 	private:
 		/**
 		/**
 		 * @brief	Translates render system type into library name.
 		 * @brief	Translates render system type into library name.

+ 25 - 12
BansheeEngine/Include/BsScriptManager.h

@@ -6,12 +6,12 @@
 namespace BansheeEngine 
 namespace BansheeEngine 
 {
 {
 	/**
 	/**
-	 * @brief	Abstraction of a specific scripting system.
+	 * @brief	Abstraction that handles a specific set of script libraries.
 	 */
 	 */
-	class BS_EXPORT ScriptSystem
+	class BS_EXPORT ScriptLibrary
 	{
 	{
 	public:
 	public:
-		virtual ~ScriptSystem() { }
+		virtual ~ScriptLibrary() { }
 
 
 		/**
 		/**
 		 * @brief	Called when the script system is being activated.
 		 * @brief	Called when the script system is being activated.
@@ -19,7 +19,13 @@ namespace BansheeEngine
 		virtual void initialize() = 0;
 		virtual void initialize() = 0;
 
 
 		/**
 		/**
-		 * @brief	Called when the script system is being destryoed.
+		 * @brief	Called when the script libraries should be reloaded.
+		 *			(e.g. when they are recompiled).
+		 */
+		virtual void reload() = 0;
+
+		/**
+		 * @brief	Called when the script system is being destroyed.
 		 */
 		 */
 		virtual void destroy() = 0;
 		virtual void destroy() = 0;
 	};
 	};
@@ -34,23 +40,30 @@ namespace BansheeEngine
 		~ScriptManager() { }
 		~ScriptManager() { }
 
 
 		/**
 		/**
-		 * @brief	Initializes the script managed with the specified script system,
-		 *			making it active. Should be called right after construction.
+		 * @brief	Initializes the currently active script library loading the scripts
+		 *			contained within.
+		 */
+		void initialize();
+
+		/**
+		 * @brief	Reloads any scripts in the currently active library. Should be called after
+		 *			some change to the scripts was made (e.g. project was changed, or scripts were
+		 *			recompiled).
 		 */
 		 */
-		void initialize(const std::shared_ptr<ScriptSystem>& scriptSystem);
+		void reload();
 
 
 		/**
 		/**
-		 * @brief	Destroys the currently active script system. Must be called just
-		 *			before shutdown.
+		 * @brief	Sets the active script library that controls what kind and which
+		 *			scripts are loaded.
 		 */
 		 */
-		void destroy();
+		void _setScriptLibrary(const SPtr<ScriptLibrary>& library);
 
 
 	private:
 	private:
 		/**
 		/**
 		 * @copydoc	ScriptManager::onShutDown
 		 * @copydoc	ScriptManager::onShutDown
 		 */
 		 */
-		void onShutDown();
+		void onShutDown() override;
 
 
-		std::shared_ptr<ScriptSystem> mScriptSystem;
+		SPtr<ScriptLibrary> mScriptLibrary;
 	};
 	};
 }
 }

+ 23 - 18
BansheeEngine/Source/BsApplication.cpp

@@ -57,7 +57,6 @@ namespace BansheeEngine
 		GUIManager::shutDown();
 		GUIManager::shutDown();
 		GUIMaterialManager::shutDown();
 		GUIMaterialManager::shutDown();
 		BuiltinResources::shutDown();
 		BuiltinResources::shutDown();
-		ScriptManager::shutDown();
 		VirtualInput::shutDown();
 		VirtualInput::shutDown();
 	}
 	}
 
 
@@ -69,7 +68,6 @@ namespace BansheeEngine
 		Importer::instance()._registerAssetImporter(importer);
 		Importer::instance()._registerAssetImporter(importer);
 
 
 		VirtualInput::startUp();
 		VirtualInput::startUp();
-		ScriptManager::startUp();
 		BuiltinResources::startUp();
 		BuiltinResources::startUp();
 		GUIManager::startUp();
 		GUIManager::startUp();
 		GUIMaterialManager::startUp();
 		GUIMaterialManager::startUp();
@@ -77,13 +75,10 @@ namespace BansheeEngine
 		ShortcutManager::startUp();
 		ShortcutManager::startUp();
 
 
 		Cursor::startUp();
 		Cursor::startUp();
-
-#if BS_VER == BS_VER_DEV
-		loadPlugin("BansheeMono", &mMonoPlugin);
-		loadPlugin("SBansheeEngine", &mSBansheeEnginePlugin); // Scripting interface
-#endif
-
 		Cursor::instance().setCursor(CursorType::Arrow);
 		Cursor::instance().setCursor(CursorType::Arrow);
+
+		loadScriptSystem();
+		ScriptManager::instance().initialize();
 	}
 	}
 
 
 	void Application::onShutDown()
 	void Application::onShutDown()
@@ -92,16 +87,7 @@ namespace BansheeEngine
 		// could have allocated parts or all of those objects.
 		// could have allocated parts or all of those objects.
 		SceneManager::instance().clearScene(true);
 		SceneManager::instance().clearScene(true);
 
 
-		// These plugins must be unloaded before any other script plugins, because
-		// they will cause finalizers to trigger and various modules those finalizers
-		// might reference must still be active
-#if BS_VER == BS_VER_DEV
-		shutdownPlugin(mSBansheeEnginePlugin);
-		unloadPlugin(mSBansheeEnginePlugin);
-
-		shutdownPlugin(mMonoPlugin);
-		unloadPlugin(mMonoPlugin);
-#endif
+		unloadScriptSystem();
 
 
 		CoreApplication::onShutDown();
 		CoreApplication::onShutDown();
 	}
 	}
@@ -125,6 +111,25 @@ namespace BansheeEngine
 		PROFILE_CALL(GUIManager::instance().update(), "GUI");
 		PROFILE_CALL(GUIManager::instance().update(), "GUI");
 	}
 	}
 
 
+	void Application::loadScriptSystem()
+	{
+		ScriptManager::startUp();
+
+		loadPlugin("BansheeMono", &mMonoPlugin);
+		loadPlugin("SBansheeEngine", &mSBansheeEnginePlugin); 
+	}
+
+	void Application::unloadScriptSystem()
+	{
+		ScriptManager::shutDown();
+
+		// These plugins must be unloaded before any other script plugins, because
+		// they will cause finalizers to trigger and various modules those finalizers
+		// might reference must still be active
+		unloadPlugin(mSBansheeEnginePlugin);
+		unloadPlugin(mMonoPlugin);
+	}
+
 	ViewportPtr Application::getPrimaryViewport() const
 	ViewportPtr Application::getPrimaryViewport() const
 	{
 	{
 		// TODO - Need a way to determine primary viewport!
 		// TODO - Need a way to determine primary viewport!

+ 13 - 7
BansheeEngine/Source/BsScriptManager.cpp

@@ -2,20 +2,26 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	void ScriptManager::initialize(const std::shared_ptr<ScriptSystem>& scriptSystem)
+	void ScriptManager::initialize()
 	{
 	{
-		mScriptSystem = scriptSystem;
-		mScriptSystem->initialize();
+		if (mScriptLibrary != nullptr)
+			mScriptLibrary->initialize();
 	}
 	}
 
 
-	void ScriptManager::destroy()
+	void ScriptManager::reload()
 	{
 	{
-		if (mScriptSystem != nullptr)
-			mScriptSystem->destroy();
+		if (mScriptLibrary != nullptr)
+			mScriptLibrary->reload();
 	}
 	}
 
 
 	void ScriptManager::onShutDown()
 	void ScriptManager::onShutDown()
 	{
 	{
-		mScriptSystem = nullptr;
+		if (mScriptLibrary != nullptr)
+			mScriptLibrary->destroy();
+	}
+
+	void ScriptManager::_setScriptLibrary(const SPtr<ScriptLibrary>& library)
+	{
+		mScriptLibrary = library;
 	}
 	}
 }
 }

+ 0 - 2
BansheeMono/BansheeMono.vcxproj

@@ -242,7 +242,6 @@
     <ClInclude Include="Include\BsMonoMethod.h" />
     <ClInclude Include="Include\BsMonoMethod.h" />
     <ClInclude Include="Include\BsMonoPrerequisites.h" />
     <ClInclude Include="Include\BsMonoPrerequisites.h" />
     <ClInclude Include="Include\BsMonoProperty.h" />
     <ClInclude Include="Include\BsMonoProperty.h" />
-    <ClInclude Include="Include\BsMonoScriptManager.h" />
     <ClInclude Include="Include\BsMonoUtil.h" />
     <ClInclude Include="Include\BsMonoUtil.h" />
     <ClInclude Include="Include\BsScriptMeta.h" />
     <ClInclude Include="Include\BsScriptMeta.h" />
   </ItemGroup>
   </ItemGroup>
@@ -255,7 +254,6 @@
     <ClCompile Include="Source\BsMonoMethod.cpp" />
     <ClCompile Include="Source\BsMonoMethod.cpp" />
     <ClCompile Include="Source\BsMonoPlugin.cpp" />
     <ClCompile Include="Source\BsMonoPlugin.cpp" />
     <ClCompile Include="Source\BsMonoProperty.cpp" />
     <ClCompile Include="Source\BsMonoProperty.cpp" />
-    <ClCompile Include="Source\BsMonoScriptManager.cpp" />
     <ClCompile Include="Source\BsMonoUtil.cpp" />
     <ClCompile Include="Source\BsMonoUtil.cpp" />
     <ClCompile Include="Source\BsScriptMeta.cpp" />
     <ClCompile Include="Source\BsScriptMeta.cpp" />
   </ItemGroup>
   </ItemGroup>

+ 0 - 6
BansheeMono/BansheeMono.vcxproj.filters

@@ -36,9 +36,6 @@
     <ClInclude Include="Include\BsMonoProperty.h">
     <ClInclude Include="Include\BsMonoProperty.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\BsMonoScriptManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsMonoUtil.h">
     <ClInclude Include="Include\BsMonoUtil.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
@@ -74,9 +71,6 @@
     <ClCompile Include="Source\BsScriptMeta.cpp">
     <ClCompile Include="Source\BsScriptMeta.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\BsMonoScriptManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsMonoUtil.cpp">
     <ClCompile Include="Source\BsMonoUtil.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>

+ 0 - 31
BansheeMono/Include/BsMonoScriptManager.h

@@ -1,31 +0,0 @@
-#pragma once
-
-#include "BsMonoPrerequisites.h"
-#include "BsScriptManager.h"
-#include "BsModule.h"
-
-namespace BansheeEngine 
-{
-	/**
-	 * @brief	Handles Mono and script system initialization and destruction.
-	 */
-	class BS_MONO_EXPORT MonoScriptSystem : public ScriptSystem
-	{
-	public:
-		MonoScriptSystem();
-		~MonoScriptSystem();
-
-		/**
-		 * @copydoc	ScriptSystem::initialize
-		 */
-		virtual void initialize();
-
-		/**
-		 * @copydoc	ScriptSystem::destroy
-		 */
-		virtual void destroy();
-
-	private:
-		bool mIsInitialized;
-	};
-}

+ 1 - 1
BansheeMono/Source/BsMonoManager.cpp

@@ -211,7 +211,7 @@ namespace BansheeEngine
 		for (auto& assemblyEntry : mAssemblies)
 		for (auto& assemblyEntry : mAssemblies)
 			assemblyEntry.second->unload();
 			assemblyEntry.second->unload();
 
 
-		mAssemblies.erase("corlib");
+		mAssemblies.clear();
 		mIsCoreLoaded = false;
 		mIsCoreLoaded = false;
 	}
 	}
 
 

+ 0 - 9
BansheeMono/Source/BsMonoPlugin.cpp

@@ -1,5 +1,4 @@
 #include "BsMonoPrerequisites.h"
 #include "BsMonoPrerequisites.h"
-#include "BsMonoScriptManager.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -8,12 +7,4 @@ namespace BansheeEngine
 		static String pluginName = "BansheeMono";
 		static String pluginName = "BansheeMono";
 		return pluginName;
 		return pluginName;
 	}
 	}
-
-	extern "C" BS_MONO_EXPORT void* loadPlugin()
-	{
-		std::shared_ptr<MonoScriptSystem> mono = bs_shared_ptr_new<MonoScriptSystem>();
-		ScriptManager::instance().initialize(mono);
-
-		return nullptr;
-	}
 }
 }

+ 0 - 32
BansheeMono/Source/BsMonoScriptManager.cpp

@@ -1,32 +0,0 @@
-#include "BsMonoScriptManager.h"
-#include "BsMonoManager.h"
-
-namespace BansheeEngine
-{
-	MonoScriptSystem::MonoScriptSystem()
-		:mIsInitialized(false)
-	{
-
-	}
-
-	MonoScriptSystem::~MonoScriptSystem()
-	{
-		if(mIsInitialized)
-			MonoManager::shutDown();
-	}
-
-	void MonoScriptSystem::initialize()
-	{
-		MonoManager::startUp();
-		mIsInitialized = true;
-	}
-
-	void MonoScriptSystem::destroy()
-	{
-		if (mIsInitialized)
-		{
-			MonoManager::shutDown();
-			mIsInitialized = false;
-		}
-	}
-}

File diff suppressed because it is too large
+ 557 - 544
BansheeSL/BsLexerFX.c


+ 1 - 1
BansheeSL/BsLexerFX.h

@@ -335,7 +335,7 @@ extern int yylex \
 #undef YY_DECL
 #undef YY_DECL
 #endif
 #endif
 
 
-#line 228 "BsLexerFX.l"
+#line 229 "BsLexerFX.l"
 
 
 #line 341 "BsLexerFX.h"
 #line 341 "BsLexerFX.h"
 #undef yyIN_HEADER
 #undef yyIN_HEADER

File diff suppressed because it is too large
+ 501 - 521
BansheeSL/BsParserFX.c


+ 58 - 57
BansheeSL/BsParserFX.h

@@ -130,62 +130,63 @@ extern int yydebug;
      TOKEN_SEPARABLE = 308,
      TOKEN_SEPARABLE = 308,
      TOKEN_QUEUE = 309,
      TOKEN_QUEUE = 309,
      TOKEN_PRIORITY = 310,
      TOKEN_PRIORITY = 310,
-     TOKEN_PARAMETERS = 311,
-     TOKEN_BLOCKS = 312,
-     TOKEN_TECHNIQUE = 313,
-     TOKEN_RENDERER = 314,
-     TOKEN_LANGUAGE = 315,
-     TOKEN_INCLUDE = 316,
-     TOKEN_PASS = 317,
-     TOKEN_VERTEX = 318,
-     TOKEN_FRAGMENT = 319,
-     TOKEN_GEOMETRY = 320,
-     TOKEN_HULL = 321,
-     TOKEN_DOMAIN = 322,
-     TOKEN_COMPUTE = 323,
-     TOKEN_COMMON = 324,
-     TOKEN_STENCILREF = 325,
-     TOKEN_FILLMODE = 326,
-     TOKEN_CULLMODE = 327,
-     TOKEN_DEPTHBIAS = 328,
-     TOKEN_SDEPTHBIAS = 329,
-     TOKEN_DEPTHCLIP = 330,
-     TOKEN_SCISSOR = 331,
-     TOKEN_MULTISAMPLE = 332,
-     TOKEN_AALINE = 333,
-     TOKEN_DEPTHREAD = 334,
-     TOKEN_DEPTHWRITE = 335,
-     TOKEN_COMPAREFUNC = 336,
-     TOKEN_STENCIL = 337,
-     TOKEN_STENCILREADMASK = 338,
-     TOKEN_STENCILWRITEMASK = 339,
-     TOKEN_STENCILOPFRONT = 340,
-     TOKEN_STENCILOPBACK = 341,
-     TOKEN_FAIL = 342,
-     TOKEN_ZFAIL = 343,
-     TOKEN_ALPHATOCOVERAGE = 344,
-     TOKEN_INDEPENDANTBLEND = 345,
-     TOKEN_TARGET = 346,
-     TOKEN_INDEX = 347,
-     TOKEN_BLEND = 348,
-     TOKEN_COLOR = 349,
-     TOKEN_ALPHA = 350,
-     TOKEN_WRITEMASK = 351,
-     TOKEN_SOURCE = 352,
-     TOKEN_DEST = 353,
-     TOKEN_OP = 354,
-     TOKEN_ADDRMODE = 355,
-     TOKEN_MINFILTER = 356,
-     TOKEN_MAGFILTER = 357,
-     TOKEN_MIPFILTER = 358,
-     TOKEN_MAXANISO = 359,
-     TOKEN_MIPBIAS = 360,
-     TOKEN_MIPMIN = 361,
-     TOKEN_MIPMAX = 362,
-     TOKEN_BORDERCOLOR = 363,
-     TOKEN_U = 364,
-     TOKEN_V = 365,
-     TOKEN_W = 366
+     TOKEN_TRANSPARENT = 311,
+     TOKEN_PARAMETERS = 312,
+     TOKEN_BLOCKS = 313,
+     TOKEN_TECHNIQUE = 314,
+     TOKEN_RENDERER = 315,
+     TOKEN_LANGUAGE = 316,
+     TOKEN_INCLUDE = 317,
+     TOKEN_PASS = 318,
+     TOKEN_VERTEX = 319,
+     TOKEN_FRAGMENT = 320,
+     TOKEN_GEOMETRY = 321,
+     TOKEN_HULL = 322,
+     TOKEN_DOMAIN = 323,
+     TOKEN_COMPUTE = 324,
+     TOKEN_COMMON = 325,
+     TOKEN_STENCILREF = 326,
+     TOKEN_FILLMODE = 327,
+     TOKEN_CULLMODE = 328,
+     TOKEN_DEPTHBIAS = 329,
+     TOKEN_SDEPTHBIAS = 330,
+     TOKEN_DEPTHCLIP = 331,
+     TOKEN_SCISSOR = 332,
+     TOKEN_MULTISAMPLE = 333,
+     TOKEN_AALINE = 334,
+     TOKEN_DEPTHREAD = 335,
+     TOKEN_DEPTHWRITE = 336,
+     TOKEN_COMPAREFUNC = 337,
+     TOKEN_STENCIL = 338,
+     TOKEN_STENCILREADMASK = 339,
+     TOKEN_STENCILWRITEMASK = 340,
+     TOKEN_STENCILOPFRONT = 341,
+     TOKEN_STENCILOPBACK = 342,
+     TOKEN_FAIL = 343,
+     TOKEN_ZFAIL = 344,
+     TOKEN_ALPHATOCOVERAGE = 345,
+     TOKEN_INDEPENDANTBLEND = 346,
+     TOKEN_TARGET = 347,
+     TOKEN_INDEX = 348,
+     TOKEN_BLEND = 349,
+     TOKEN_COLOR = 350,
+     TOKEN_ALPHA = 351,
+     TOKEN_WRITEMASK = 352,
+     TOKEN_SOURCE = 353,
+     TOKEN_DEST = 354,
+     TOKEN_OP = 355,
+     TOKEN_ADDRMODE = 356,
+     TOKEN_MINFILTER = 357,
+     TOKEN_MAGFILTER = 358,
+     TOKEN_MIPFILTER = 359,
+     TOKEN_MAXANISO = 360,
+     TOKEN_MIPBIAS = 361,
+     TOKEN_MIPMIN = 362,
+     TOKEN_MIPMAX = 363,
+     TOKEN_BORDERCOLOR = 364,
+     TOKEN_U = 365,
+     TOKEN_V = 366,
+     TOKEN_W = 367
    };
    };
 #endif
 #endif
 
 
@@ -204,7 +205,7 @@ typedef union YYSTYPE
 
 
 
 
 /* Line 2579 of glr.c  */
 /* Line 2579 of glr.c  */
-#line 208 "BsParserFX.h"
+#line 209 "BsParserFX.h"
 } YYSTYPE;
 } YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_TRIVIAL 1
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */

+ 0 - 1
MBansheeEditor/ProjectWindow.cs

@@ -84,7 +84,6 @@ namespace BansheeEditor
             {
             {
                 // Remove invalid project from recent projects list
                 // Remove invalid project from recent projects list
                 RecentProject[] recentProjects = EditorSettings.RecentProjects;
                 RecentProject[] recentProjects = EditorSettings.RecentProjects;
-                bool foundPath = false;
                 for (int i = 0; i < recentProjects.Length; i++)
                 for (int i = 0; i < recentProjects.Length; i++)
                 {
                 {
                     if (PathEx.Compare(recentProjects[i].path, projectPath))
                     if (PathEx.Compare(recentProjects[i].path, projectPath))

+ 30 - 0
SBansheeEditor/Include/BsEditorScriptLibrary.h

@@ -0,0 +1,30 @@
+#pragma once
+
+#include "BsScriptEditorPrerequisites.h"
+#include "BsEngineScriptLibrary.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Handles initialization/shutdown of the script systems and 
+	 *			loading/refresh of engine and editor-specific assemblies.
+	 */
+	class BS_SCR_BED_EXPORT EditorScriptLibrary : public EngineScriptLibrary
+	{
+	public:
+		/**
+		 * @copydoc	ScriptLibrary::initialize
+		 */
+		void initialize() override;
+
+		/**
+		 * @copydoc	ScriptLibrary::reload
+		 */
+		void reload() override;
+
+		/**
+		 * @copydoc	ScriptLibrary::destroy
+		 */
+		void destroy() override;
+	};
+}

+ 2 - 0
SBansheeEditor/SBansheeEditor.vcxproj

@@ -233,6 +233,7 @@
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsEditorResourceLoader.h" />
     <ClInclude Include="Include\BsEditorResourceLoader.h" />
+    <ClInclude Include="Include\BsEditorScriptLibrary.h" />
     <ClInclude Include="Include\BsEditorScriptManager.h" />
     <ClInclude Include="Include\BsEditorScriptManager.h" />
     <ClInclude Include="Include\BsGUIGameObjectField.h" />
     <ClInclude Include="Include\BsGUIGameObjectField.h" />
     <ClInclude Include="Include\BsGUIResourceField.h" />
     <ClInclude Include="Include\BsGUIResourceField.h" />
@@ -288,6 +289,7 @@
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsEditorResourceLoader.cpp" />
     <ClCompile Include="Source\BsEditorResourceLoader.cpp" />
+    <ClCompile Include="Source\BsEditorScriptLibrary.cpp" />
     <ClCompile Include="Source\BsGUITextureField.cpp" />
     <ClCompile Include="Source\BsGUITextureField.cpp" />
     <ClCompile Include="Source\BsMenuItemManager.cpp" />
     <ClCompile Include="Source\BsMenuItemManager.cpp" />
     <ClCompile Include="Source\BsScriptBuildManager.cpp" />
     <ClCompile Include="Source\BsScriptBuildManager.cpp" />

+ 6 - 0
SBansheeEditor/SBansheeEditor.vcxproj.filters

@@ -174,6 +174,9 @@
     <ClInclude Include="Include\BsScriptProjectSettings.h">
     <ClInclude Include="Include\BsScriptProjectSettings.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsEditorScriptLibrary.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp">
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp">
@@ -335,5 +338,8 @@
     <ClCompile Include="Source\BsScriptProjectSettings.cpp">
     <ClCompile Include="Source\BsScriptProjectSettings.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsEditorScriptLibrary.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 49 - 0
SBansheeEditor/Source/BsEditorScriptLibrary.cpp

@@ -0,0 +1,49 @@
+#include "BsEditorScriptLibrary.h"
+#include "BsEditorScriptManager.h"
+#include "BsEditorApplication.h"
+#include "BsScriptObjectManager.h"
+#include "BsFileSystem.h"
+
+namespace BansheeEngine
+{
+	void EditorScriptLibrary::initialize()
+	{
+		EngineScriptLibrary::initialize();
+
+		EditorScriptManager::startUp();
+	}
+
+	void EditorScriptLibrary::reload()
+	{
+		Vector<std::pair<String, Path>> assemblies;
+
+		Path engineAssemblyPath = gApplication().getEngineAssemblyPath();
+		assemblies.push_back({ ENGINE_ASSEMBLY, engineAssemblyPath });
+
+		if (gEditorApplication().isProjectLoaded())
+		{
+			Path gameAssemblyPath = gApplication().getGameAssemblyPath();
+			if (FileSystem::exists(gameAssemblyPath))
+				assemblies.push_back({ SCRIPT_GAME_ASSEMBLY, gameAssemblyPath });
+		}
+
+		String editorAssemblyPath = gEditorApplication().getEditorAssemblyPath().toString();
+		assemblies.push_back({ EDITOR_ASSEMBLY, editorAssemblyPath });
+
+		if (gEditorApplication().isProjectLoaded())
+		{
+			Path editorScriptAssemblyPath = gEditorApplication().getEditorScriptAssemblyPath();
+			if (FileSystem::exists(editorScriptAssemblyPath))
+				assemblies.push_back({ SCRIPT_EDITOR_ASSEMBLY, editorScriptAssemblyPath });
+		}
+
+		ScriptObjectManager::instance().refreshAssemblies(assemblies);
+	}
+
+	void EditorScriptLibrary::destroy()
+	{
+		EditorScriptManager::shutDown();
+
+		EngineScriptLibrary::destroy();
+	}
+}

+ 2 - 3
SBansheeEditor/Source/BsEditorScriptManager.cpp

@@ -19,6 +19,7 @@
 #include "BsScriptSelection.h"
 #include "BsScriptSelection.h"
 #include "BsTestOutput.h"
 #include "BsTestOutput.h"
 #include "BsEditorResourceLoader.h"
 #include "BsEditorResourceLoader.h"
+#include "BsScriptManager.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -89,7 +90,7 @@ namespace BansheeEngine
 
 
 		if (mDebugRefresh)
 		if (mDebugRefresh)
 		{
 		{
-			ScriptObjectManager::instance().refreshAssemblies();
+			ScriptManager::instance().reload();
 			mDebugRefresh = false;
 			mDebugRefresh = false;
 		}
 		}
 
 
@@ -119,8 +120,6 @@ namespace BansheeEngine
 		const String editorAssemblyPath = gEditorApplication().getEditorAssemblyPath().toString();
 		const String editorAssemblyPath = gEditorApplication().getEditorAssemblyPath().toString();
 		mEditorAssembly = &MonoManager::instance().loadAssembly(editorAssemblyPath, EDITOR_ASSEMBLY);
 		mEditorAssembly = &MonoManager::instance().loadAssembly(editorAssemblyPath, EDITOR_ASSEMBLY);
 
 
-		// TODO - Load Editor script assembly (gEditorApplication.getEditorScriptAssemblyPath())
-
 		mProgramEdClass = mEditorAssembly->getClass("BansheeEditor", "Program");
 		mProgramEdClass = mEditorAssembly->getClass("BansheeEditor", "Program");
 		mUpdateMethod = mProgramEdClass->getMethod("OnEditorUpdate");
 		mUpdateMethod = mProgramEdClass->getMethod("OnEditorUpdate");
 
 

+ 4 - 11
SBansheeEditor/Source/BsScriptEditorPlugin.cpp

@@ -1,5 +1,7 @@
 #include "BsScriptEditorPrerequisites.h"
 #include "BsScriptEditorPrerequisites.h"
 #include "BsEditorScriptManager.h"
 #include "BsEditorScriptManager.h"
+#include "BsEditorScriptLibrary.h"
+#include "BsScriptManager.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -11,7 +13,8 @@ namespace BansheeEngine
 
 
 	extern "C" BS_SCR_BED_EXPORT void* loadPlugin()
 	extern "C" BS_SCR_BED_EXPORT void* loadPlugin()
 	{
 	{
-		EditorScriptManager::startUp();
+		SPtr<EditorScriptLibrary> library = bs_shared_ptr_new<EditorScriptLibrary>();
+		ScriptManager::instance()._setScriptLibrary(library);
 
 
 		return nullptr;
 		return nullptr;
 	}
 	}
@@ -20,14 +23,4 @@ namespace BansheeEngine
 	{
 	{
 		EditorScriptManager::instance().update();
 		EditorScriptManager::instance().update();
 	}
 	}
-
-	extern "C" BS_SCR_BED_EXPORT void shutdownPlugin()
-	{
-		EditorScriptManager::shutDown();
-	}
-
-	extern "C" BS_SCR_BED_EXPORT void unloadPlugin()
-	{
-		
-	}
 }
 }

+ 30 - 0
SBansheeEngine/Include/BsEngineScriptLibrary.h

@@ -0,0 +1,30 @@
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptManager.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Handles initialization/shutdown of the script systems and 
+	 *			loading/refresh of engine-specific assemblies.
+	 */
+	class BS_SCR_BE_EXPORT EngineScriptLibrary : public ScriptLibrary
+	{
+	public:
+		/**
+		 * @copydoc	ScriptLibrary::initialize
+		 */
+		void initialize() override;
+
+		/**
+		 * @copydoc	ScriptLibrary::reload
+		 */
+		void reload() override;
+
+		/**
+		 * @copydoc	ScriptLibrary::destroy
+		 */
+		void destroy() override;
+	};
+}

+ 2 - 3
SBansheeEngine/Include/BsScriptAssemblyManager.h

@@ -25,10 +25,9 @@ namespace BansheeEngine
 		void loadAssemblyInfo(const String& assemblyName);
 		void loadAssemblyInfo(const String& assemblyName);
 
 
 		/**
 		/**
-		 * @brief	Reloads assembly data for all assemblies that were previously loaded using
-		 *			::loadAssemblyInfo. Useful for quickly updating all data after an assembly reload.
+		 * @brief	Clears any assembly data previously loaded with ::loadAssemblyInfo.
 		 */
 		 */
-		void refreshAssemblyInfo();
+		void clearAssemblyInfo();
 
 
 		/**
 		/**
 		 * @brief	Returns managed serializable object info for a specific managed type.
 		 * @brief	Returns managed serializable object info for a specific managed type.

+ 8 - 4
SBansheeEngine/Include/BsScriptObjectManager.h

@@ -25,11 +25,15 @@ namespace BansheeEngine
 		void unregisterScriptObject(ScriptObjectBase* instance);
 		void unregisterScriptObject(ScriptObjectBase* instance);
 
 
 		/**
 		/**
-		 * @brief	Reloads all script assemblies. This involves backup up managed
-		 *			object data, destroying all managed objects and restoring
-		 *			the objects after reload.
+		 * @brief	Refreshes the list of active assemblies. Unloads all current assemblies and loads 
+		 *			the newly provided set. This involves backup up managed object data, destroying all 
+		 *			managed objects and restoring the objects after reload.
+		 *
+		 * @param	assemblies	A list of assembly names and paths to load. First value represents
+		 *						the assembly name, and second a path its the assembly .dll.
+		 *						Assemblies will be loaded in order specified.
 		 */
 		 */
-		void refreshAssemblies();
+		void refreshAssemblies(const Vector<std::pair<String, Path>>& assemblies);
 
 
 		/**
 		/**
 		 * @brief	Called once per frame. Triggers queued finalizer callbacks.
 		 * @brief	Called once per frame. Triggers queued finalizer callbacks.

+ 2 - 0
SBansheeEngine/SBansheeEngine.vcxproj

@@ -232,6 +232,7 @@
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClInclude Include="Include\BsEngineScriptLibrary.h" />
     <ClInclude Include="Include\BsGameResourceManager.h" />
     <ClInclude Include="Include\BsGameResourceManager.h" />
     <ClInclude Include="Include\BsManagedComponent.h" />
     <ClInclude Include="Include\BsManagedComponent.h" />
     <ClInclude Include="Include\BsManagedComponentRTTI.h" />
     <ClInclude Include="Include\BsManagedComponentRTTI.h" />
@@ -336,6 +337,7 @@
     <ClInclude Include="Include\BsScriptVirtualInput.h" />
     <ClInclude Include="Include\BsScriptVirtualInput.h" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClCompile Include="Source\BsEngineScriptLibrary.cpp" />
     <ClCompile Include="Source\BsGameResourceManager.cpp" />
     <ClCompile Include="Source\BsGameResourceManager.cpp" />
     <ClCompile Include="Source\BsManagedComponent.cpp" />
     <ClCompile Include="Source\BsManagedComponent.cpp" />
     <ClCompile Include="Source\BsManagedDiff.cpp" />
     <ClCompile Include="Source\BsManagedDiff.cpp" />

+ 6 - 0
SBansheeEngine/SBansheeEngine.vcxproj.filters

@@ -339,6 +339,9 @@
     <ClInclude Include="Include\BsScriptResources.h">
     <ClInclude Include="Include\BsScriptResources.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsEngineScriptLibrary.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
@@ -617,5 +620,8 @@
     <ClCompile Include="Source\BsScriptResources.cpp">
     <ClCompile Include="Source\BsScriptResources.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsEngineScriptLibrary.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 67 - 0
SBansheeEngine/Source/BsEngineScriptLibrary.cpp

@@ -0,0 +1,67 @@
+#include "BsEngineScriptLibrary.h"
+#include "BsMonoManager.h"
+#include "BsMonoAssembly.h"
+#include "BsScriptAssemblyManager.h"
+#include "BsScriptResourceManager.h"
+#include "BsScriptGameObjectManager.h"
+#include "BsManagedResourceManager.h"
+#include "BsScriptManager.h"
+#include "BsScriptInput.h"
+#include "BsScriptVirtualInput.h"
+#include "BsScriptObjectManager.h"
+#include "BsGameResourceManager.h"
+#include "BsApplication.h"
+#include "BsFileSystem.h"
+
+namespace BansheeEngine
+{
+	void EngineScriptLibrary::initialize()
+	{
+		Path engineAssemblyPath = gApplication().getEngineAssemblyPath();
+		const String ASSEMBLY_ENTRY_POINT = "Program::Start";
+
+		MonoManager::startUp();
+		MonoAssembly& bansheeEngineAssembly = MonoManager::instance().loadAssembly(engineAssemblyPath.toString(), ENGINE_ASSEMBLY);
+
+		GameResourceManager::startUp();
+		ScriptObjectManager::startUp();
+		ManagedResourceManager::startUp();
+		ScriptAssemblyManager::startUp();
+		ScriptResourceManager::startUp();
+		ScriptGameObjectManager::startUp();
+		ScriptInput::startUp();
+		ScriptVirtualInput::startUp();
+
+		ScriptAssemblyManager::instance().loadAssemblyInfo(ENGINE_ASSEMBLY);
+		bansheeEngineAssembly.invoke(ASSEMBLY_ENTRY_POINT);
+	}
+
+	void EngineScriptLibrary::reload()
+	{
+		Path engineAssemblyPath = gApplication().getEngineAssemblyPath();
+		Path gameAssemblyPath = gApplication().getGameAssemblyPath();
+
+		Vector<std::pair<String, Path>> assemblies;
+		assemblies.push_back({ ENGINE_ASSEMBLY, engineAssemblyPath });
+
+		if (FileSystem::exists(gameAssemblyPath))
+			assemblies.push_back({ SCRIPT_GAME_ASSEMBLY, gameAssemblyPath });
+
+		ScriptObjectManager::instance().refreshAssemblies(assemblies);
+	}
+
+	void EngineScriptLibrary::destroy()
+	{
+		ScriptVirtualInput::shutDown();
+		ScriptInput::shutDown();
+		ManagedResourceManager::shutDown();
+		MonoManager::shutDown();
+		ScriptObjectManager::instance().processFinalizedObjects();
+
+		ScriptGameObjectManager::shutDown();
+		ScriptResourceManager::shutDown();
+		ScriptAssemblyManager::shutDown();
+		ScriptObjectManager::shutDown();
+		GameResourceManager::shutDown();
+	}
+}

+ 2 - 8
SBansheeEngine/Source/BsScriptAssemblyManager.cpp

@@ -163,16 +163,10 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void ScriptAssemblyManager::refreshAssemblyInfo()
+	void ScriptAssemblyManager::clearAssemblyInfo()
 	{
 	{
-		for (auto& assemblyInfoEntry : mAssemblyInfos)
-			assemblyInfoEntry.second = nullptr;
-
 		clearScriptObjects();
 		clearScriptObjects();
-		for (auto& assemblyInfoEntry : mAssemblyInfos)
-		{
-			loadAssemblyInfo(assemblyInfoEntry.first);
-		}
+		mAssemblyInfos.clear();
 	}
 	}
 
 
 	ManagedSerializableTypeInfoPtr ScriptAssemblyManager::determineType(MonoClass* monoClass)
 	ManagedSerializableTypeInfoPtr ScriptAssemblyManager::determineType(MonoClass* monoClass)

+ 4 - 45
SBansheeEngine/Source/BsScriptEnginePlugin.cpp

@@ -1,16 +1,7 @@
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptEnginePrerequisites.h"
-#include "BsMonoManager.h"
-#include "BsMonoAssembly.h"
-#include "BsScriptAssemblyManager.h"
-#include "BsScriptResourceManager.h"
-#include "BsScriptGameObjectManager.h"
-#include "BsManagedResourceManager.h"
-#include "BsScriptManager.h"
-#include "BsScriptInput.h"
-#include "BsScriptVirtualInput.h"
 #include "BsScriptObjectManager.h"
 #include "BsScriptObjectManager.h"
-#include "BsGameResourceManager.h"
-#include "BsApplication.h"
+#include "BsEngineScriptLibrary.h"
+#include "BsScriptManager.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -22,25 +13,8 @@ namespace BansheeEngine
 
 
 	extern "C" BS_SCR_BE_EXPORT void* loadPlugin()
 	extern "C" BS_SCR_BE_EXPORT void* loadPlugin()
 	{
 	{
-		Path engineAssemblyPath = gApplication().getEngineAssemblyPath();
-		const String ASSEMBLY_ENTRY_POINT = "Program::Start";
-
-		MonoAssembly& bansheeEngineAssembly = MonoManager::instance().loadAssembly(engineAssemblyPath.toString(), ENGINE_ASSEMBLY);
-
-		// TODO - Load Game assembly (gApplication().getGameAssemblyPath())
-
-		GameResourceManager::startUp();
-		ScriptObjectManager::startUp();
-		ManagedResourceManager::startUp();
-		ScriptAssemblyManager::startUp();
-		ScriptResourceManager::startUp();
-		ScriptGameObjectManager::startUp();
-		ScriptInput::startUp();
-		ScriptVirtualInput::startUp();
-
-		ScriptAssemblyManager::instance().loadAssemblyInfo(ENGINE_ASSEMBLY);
-
-		bansheeEngineAssembly.invoke(ASSEMBLY_ENTRY_POINT);
+		SPtr<EngineScriptLibrary> library = bs_shared_ptr_new<EngineScriptLibrary>();
+		ScriptManager::instance()._setScriptLibrary(library);
 
 
 		return nullptr;
 		return nullptr;
 	}
 	}
@@ -49,19 +23,4 @@ namespace BansheeEngine
 	{
 	{
 		ScriptObjectManager::instance().update();
 		ScriptObjectManager::instance().update();
 	}
 	}
-
-	extern "C" BS_SCR_BE_EXPORT void unloadPlugin()
-	{
-		ScriptVirtualInput::shutDown();
-		ScriptInput::shutDown();
-		ManagedResourceManager::shutDown();
-		ScriptManager::instance().destroy();
-		ScriptObjectManager::instance().processFinalizedObjects();
-
-		ScriptGameObjectManager::shutDown();
-		ScriptResourceManager::shutDown();
-		ScriptAssemblyManager::shutDown();
-		ScriptObjectManager::shutDown();
-		GameResourceManager::shutDown();
-	}
 }
 }

+ 9 - 3
SBansheeEngine/Source/BsScriptObjectManager.cpp

@@ -2,6 +2,7 @@
 #include "BsScriptObject.h"
 #include "BsScriptObject.h"
 #include "BsMonoManager.h"
 #include "BsMonoManager.h"
 #include "BsScriptAssemblyManager.h"
 #include "BsScriptAssemblyManager.h"
+#include "BsMonoAssembly.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -26,7 +27,7 @@ namespace BansheeEngine
 		mScriptObjects.erase(instance);
 		mScriptObjects.erase(instance);
 	}
 	}
 
 
-	void ScriptObjectManager::refreshAssemblies()
+	void ScriptObjectManager::refreshAssemblies(const Vector<std::pair<String, Path>>& assemblies)
 	{
 	{
 		Map<ScriptObjectBase*, ScriptObjectBackup> backupData;
 		Map<ScriptObjectBase*, ScriptObjectBackup> backupData;
 
 
@@ -46,8 +47,13 @@ namespace BansheeEngine
 		for (auto& scriptObject : mScriptObjects)
 		for (auto& scriptObject : mScriptObjects)
 			scriptObject->_clearManagedInstance();
 			scriptObject->_clearManagedInstance();
 
 
-		MonoManager::instance().loadScriptDomain();
-		ScriptAssemblyManager::instance().refreshAssemblyInfo();
+		ScriptAssemblyManager::instance().clearAssemblyInfo();
+
+		for (auto& assemblyPair : assemblies)
+		{
+			MonoManager::instance().loadAssembly(assemblyPair.second.toString(), assemblyPair.first);
+			ScriptAssemblyManager::instance().loadAssemblyInfo(assemblyPair.first);
+		}
 
 
 		onRefreshDomainLoaded();
 		onRefreshDomainLoaded();
 
 

+ 0 - 2
TODO.txt

@@ -63,7 +63,6 @@ EditorApplication.CreateProject not implemented
  - Copy default layout from Data/Editor to the project folder
  - Copy default layout from Data/Editor to the project folder
  - Create Resources & Internal folders
  - Create Resources & Internal folders
 
 
-TODO - On project unload and load I need to trigger assembly reload
 TODO - Test if project loading/unloading/reloading works
 TODO - Test if project loading/unloading/reloading works
 
 
 Ribek use:
 Ribek use:
@@ -117,7 +116,6 @@ Finalizing:
  - Settings/Preferences window
  - Settings/Preferences window
  - Documentation
  - Documentation
  - Need to generate a proper merge of dev and preview branches
  - Need to generate a proper merge of dev and preview branches
- - Save/Load project menu item does nothing at the moment
  - (Optionally) GUI tabbing to switch between elements
  - (Optionally) GUI tabbing to switch between elements
  - Undo/Redo
  - Undo/Redo
   - CmdRecordSO records an SO and all its children but it should only record a single SO
   - CmdRecordSO records an SO and all its children but it should only record a single SO

Some files were not shown because too many files changed in this diff