Procházet zdrojové kódy

Unsupported file types in project library will now also receive a .meta file in order to be consistent

BearishSun před 10 roky
rodič
revize
1d8dde64f3

+ 3 - 0
BansheeCore/Source/BsImporter.cpp

@@ -135,6 +135,9 @@ namespace BansheeEngine
 	SpecificImporter* Importer::getImporterForFile(const Path& inputFilePath) const
 	{
 		WString ext = inputFilePath.getWExtension();
+		if (ext.empty())
+			return nullptr;
+
 		ext = ext.substr(1, ext.size() - 1); // Remove the .
 		if(!supportsFileType(ext))
 		{

+ 19 - 18
BansheeEditor/Source/BsProjectLibrary.cpp

@@ -370,16 +370,9 @@ namespace BansheeEngine
 
 	void ProjectLibrary::reimportResourceInternal(ResourceEntry* resource, const ImportOptionsPtr& importOptions, bool forceReimport)
 	{
-		WString ext = resource->path.getWExtension();
 		Path metaPath = resource->path;
 		metaPath.setFilename(metaPath.getWFilename() + L".meta");
 
-		if (ext.size() > 0)
-			ext = ext.substr(1, ext.size() - 1); // Remove the .
-
-		if (!Importer::instance().supportsFileType(ext))
-			return;
-
 		if(resource->meta == nullptr)
 		{
 			if(FileSystem::isFile(metaPath))
@@ -416,10 +409,15 @@ namespace BansheeEngine
 			{
 				importedResource = Importer::instance().import(resource->path, curImportOptions);
 
-				ResourceMetaDataPtr subMeta = importedResource->getMetaData();
-				UINT32 typeId = importedResource->getTypeId();
+				if (importedResource != nullptr)
+				{
+					ResourceMetaDataPtr subMeta = importedResource->getMetaData();
+					UINT32 typeId = importedResource->getTypeId();
+					resource->meta = ProjectResourceMeta::create(importedResource.getUUID(), typeId, subMeta, curImportOptions);
+				}
+				else
+					resource->meta = ProjectResourceMeta::create(importedResource.getUUID(), 0, nullptr, curImportOptions);
 
-				resource->meta = ProjectResourceMeta::create(importedResource.getUUID(), typeId, subMeta, curImportOptions);
 				FileEncoder fs(metaPath);
 				fs.encode(resource->meta.get());
 
@@ -435,18 +433,21 @@ namespace BansheeEngine
 
 			addDependencies(resource);
 
-			Path internalResourcesPath = mProjectFolder;
-			internalResourcesPath.append(INTERNAL_RESOURCES_DIR);
+			if (importedResource != nullptr)
+			{
+				Path internalResourcesPath = mProjectFolder;
+				internalResourcesPath.append(INTERNAL_RESOURCES_DIR);
 
-			if(!FileSystem::isDirectory(internalResourcesPath))
-				FileSystem::createDir(internalResourcesPath);
+				if (!FileSystem::isDirectory(internalResourcesPath))
+					FileSystem::createDir(internalResourcesPath);
 
-			internalResourcesPath.setFilename(toWString(importedResource.getUUID()) + L".asset");
+				internalResourcesPath.setFilename(toWString(importedResource.getUUID()) + L".asset");
 
-			gResources().save(importedResource, internalResourcesPath, true);
-			gResources().unload(importedResource);
+				gResources().save(importedResource, internalResourcesPath, true);
+				gResources().unload(importedResource);
 
-			mResourceManifest->registerResource(importedResource.getUUID(), internalResourcesPath);
+				mResourceManifest->registerResource(importedResource.getUUID(), internalResourcesPath);
+			}
 
 			resource->lastUpdateTime = std::time(nullptr);
 		}

+ 1 - 0
MBansheeEditor/UnitTests.cs

@@ -571,6 +571,7 @@ namespace BansheeEditor
             else
                 Scene.Clear();
 
+            // TODO - This cleanup should happen regardless if unit test fails or succeeds
             ProjectLibrary.Delete("unitTest4Scene_0");
             ProjectLibrary.Delete("unitTest4Scene_1");
             ProjectLibrary.Delete("unitTest4Scene_2");