diff --git a/Source/Editor/GUI/ComboBox.cs b/Source/Editor/GUI/ComboBox.cs index da2106450..0417cc7e3 100644 --- a/Source/Editor/GUI/ComboBox.cs +++ b/Source/Editor/GUI/ComboBox.cs @@ -545,7 +545,7 @@ namespace FlaxEditor.GUI Render2D.DrawRectangle(clientRect.MakeExpanded(-2.0f), borderColor); // Check if has selected item - if (_selectedIndices.Count > 0) + if (_selectedIndices != null && _selectedIndices.Count > 0) { string text = _selectedIndices.Count == 1 ? _items[_selectedIndices[0]] : "Multiple Values"; diff --git a/Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp b/Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp index d0fba8f12..ab9b6b606 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp @@ -716,13 +716,13 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti if (EnumHasAnyFlags(data.Types, ImportDataTypes::Geometry) && context->Scene->HasMeshes()) { const int meshCount = context->Scene->mNumMeshes; - if (options.SplitObjects && options.ObjectIndex == -1) + if (options.SplitObjects && options.ObjectIndex == -1 && meshCount > 1) { // Import the first object within this call options.SplitObjects = false; options.ObjectIndex = 0; - if (meshCount > 1 && options.OnSplitImport.IsBinded()) + if (options.OnSplitImport.IsBinded()) { // Split all animations into separate assets LOG(Info, "Splitting imported {0} meshes", meshCount); @@ -789,13 +789,13 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti if (EnumHasAnyFlags(data.Types, ImportDataTypes::Animations) && context->Scene->HasAnimations()) { const int32 animCount = (int32)context->Scene->mNumAnimations; - if (options.SplitObjects && options.ObjectIndex == -1) + if (options.SplitObjects && options.ObjectIndex == -1 && animCount > 1) { // Import the first object within this call options.SplitObjects = false; options.ObjectIndex = 0; - if (animCount > 1 && options.OnSplitImport.IsBinded()) + if (options.OnSplitImport.IsBinded()) { // Split all animations into separate assets LOG(Info, "Splitting imported {0} animations", animCount); diff --git a/Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp b/Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp index 1eb9e1f27..ab55df7f6 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp @@ -1245,13 +1245,13 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt if (EnumHasAnyFlags(data.Types, ImportDataTypes::Geometry) && context->Scene->getMeshCount() > 0) { const int meshCount = context->Scene->getMeshCount(); - if (options.SplitObjects && options.ObjectIndex == -1) + if (options.SplitObjects && options.ObjectIndex == -1 && meshCount > 1) { // Import the first object within this call options.SplitObjects = false; options.ObjectIndex = 0; - if (meshCount > 1 && options.OnSplitImport.IsBinded()) + if (options.OnSplitImport.IsBinded()) { // Split all animations into separate assets LOG(Info, "Splitting imported {0} meshes", meshCount); @@ -1328,13 +1328,13 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt if (EnumHasAnyFlags(data.Types, ImportDataTypes::Animations)) { const int animCount = context->Scene->getAnimationStackCount(); - if (options.SplitObjects && options.ObjectIndex == -1) + if (options.SplitObjects && options.ObjectIndex == -1 && animCount > 1) { // Import the first object within this call options.SplitObjects = false; options.ObjectIndex = 0; - if (animCount > 1 && options.OnSplitImport.IsBinded()) + if (options.OnSplitImport.IsBinded()) { // Split all animations into separate assets LOG(Info, "Splitting imported {0} animations", animCount); diff --git a/Source/Engine/Tools/ModelTool/ModelTool.cpp b/Source/Engine/Tools/ModelTool/ModelTool.cpp index 19f203667..99873c016 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.cpp @@ -16,6 +16,7 @@ #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Graphics/Models/ModelData.h" #include "Engine/Content/Assets/Model.h" +#include "Engine/Content/Content.h" #include "Engine/Serialization/MemoryWriteStream.h" #if USE_EDITOR #include "Engine/Core/Types/DateTime.h" @@ -909,6 +910,10 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op { auto& texture = data.Textures[i]; + // When splitting imported meshes allow only the first mesh to import assets (mesh[0] is imported after all following ones so import assets during mesh[1]) + if (!options.SplitObjects && options.ObjectIndex != 1 && options.ObjectIndex != -1) + continue; + // Auto-import textures if (autoImportOutput.IsEmpty() || (data.Types & ImportDataTypes::Textures) == ImportDataTypes::None || texture.FilePath.IsEmpty()) continue; @@ -994,6 +999,17 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op materialOptions.Info.CullMode = CullMode::TwoSided; if (!Math::IsOne(material.Opacity.Value) || material.Opacity.TextureIndex != -1) materialOptions.Info.BlendMode = MaterialBlendMode::Transparent; + + // When splitting imported meshes allow only the first mesh to import assets (mesh[0] is imported after all following ones so import assets during mesh[1]) + if (!options.SplitObjects && options.ObjectIndex != 1 && options.ObjectIndex != -1) + { + // Find that asset create previously + AssetInfo info; + if (Content::GetAssetInfo(assetPath, info)) + material.AssetID = info.ID; + continue; + } + AssetsImportingManager::Create(AssetsImportingManager::CreateMaterialTag, assetPath, material.AssetID, &materialOptions); #endif }