fix a couple of bugs with importing without material instances
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#if ENABLE_ASSETS_DISCOVERY
|
||||
#include "Engine/Core/Collections/HashSet.h"
|
||||
#endif
|
||||
#include <Engine/Debug/DebugLog.h>
|
||||
|
||||
TimeSpan Content::AssetsUpdateInterval = TimeSpan::FromMilliseconds(500);
|
||||
TimeSpan Content::AssetsUnloadInterval = TimeSpan::FromSeconds(10);
|
||||
@@ -1003,6 +1004,7 @@ Asset* Content::load(const Guid& id, const ScriptingTypeHandle& type, AssetInfo&
|
||||
if (!GetAssetInfo(id, assetInfo))
|
||||
{
|
||||
LOG(Warning, "Invalid or missing asset ({0}, {1}).", id.ToString(Guid::FormatType::N), type.ToString());
|
||||
LOG(Warning, "{0}", DebugLog::GetStackTrace());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -863,18 +863,19 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
|
||||
importedFileNames.Add(filename);
|
||||
#if COMPILE_WITH_ASSETS_IMPORTER
|
||||
auto assetPath = autoImportOutput / filename + ASSET_FILES_EXTENSION_WITH_DOT;
|
||||
if (options.ImportMaterialsAsInstances) {
|
||||
LOG(Warning, "Adding material instance for {0}", assetPath);
|
||||
|
||||
if (options.ImportMaterialsAsInstances)
|
||||
{
|
||||
AssetsImportingManager::Create(AssetsImportingManager::CreateMaterialInstanceTag, assetPath, material.AssetID);
|
||||
MaterialInstance* materialInstance = (MaterialInstance*) LoadAsset(assetPath, MaterialInstance::TypeInitializer);
|
||||
if (materialInstance->WaitForLoaded()) {
|
||||
if (materialInstance->WaitForLoaded())
|
||||
{
|
||||
LOG(Error, "Failed to load material instance after creation. ({0})", assetPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
MaterialBase* materialInstanceOf = (MaterialBase*) LoadAsset(options.InstanceToImportAs, MaterialBase::TypeInitializer);
|
||||
if (materialInstanceOf->WaitForLoaded()) {
|
||||
if (materialInstanceOf->WaitForLoaded())
|
||||
{
|
||||
LOG(Error, "Failed to load material to create an instance of. ({0})", options.InstanceToImportAs);
|
||||
return true;
|
||||
}
|
||||
@@ -882,7 +883,8 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
|
||||
materialInstance->SetBaseMaterial(materialInstanceOf);
|
||||
materialInstance->Save();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
CreateMaterial::Options materialOptions;
|
||||
materialOptions.Diffuse.Color = material.Diffuse.Color;
|
||||
if (material.Diffuse.TextureIndex != -1)
|
||||
|
||||
Reference in New Issue
Block a user