Renderable now shows the name of the mesh and material assigned instead of asset IDs

This commit is contained in:
Kah Wei 2022-11-15 18:16:07 +08:00
parent c69ad04f1e
commit 958310a8ea
1 changed files with 11 additions and 9 deletions

View File

@ -368,8 +368,8 @@ namespace SHADE
DrawContextMenu(component); DrawContextMenu(component);
Handle<SHMesh> const& mesh = component->GetMesh(); Handle<SHMesh> const& mesh = component->GetMesh();
Handle<SHMaterialInstance> const& mat = component->GetMaterial(); Handle<SHMaterialInstance> const& mat = component->GetMaterial();
const auto MESH_NAME = SHResourceManager::GetAssetName<SHMesh>(mesh).value_or("");
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Mesh", std::to_string(SHResourceManager::GetAssetID<SHMesh>(mesh).value_or(0)).data(), [component]() SHEditorWidgets::DragDropReadOnlyField<AssetID>("Mesh", MESH_NAME, [component]()
{ {
Handle<SHMesh> const& mesh = component->GetMesh(); Handle<SHMesh> const& mesh = component->GetMesh();
return SHResourceManager::GetAssetID<SHMesh>(mesh).value_or(0); return SHResourceManager::GetAssetID<SHMesh>(mesh).value_or(0);
@ -380,13 +380,15 @@ namespace SHADE
SHResourceManager::FinaliseChanges(); SHResourceManager::FinaliseChanges();
}, SHDragDrop::DRAG_RESOURCE); }, SHDragDrop::DRAG_RESOURCE);
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Material", mat ? std::to_string(SHResourceManager::GetAssetID<SHMaterial>(mat->GetBaseMaterial()).value_or(0)).data() : "", [component]() const auto MAT_NAME = mat ? SHResourceManager::GetAssetName<SHMaterial>(mat->GetBaseMaterial()).value_or("") : "";
{ SHEditorWidgets::DragDropReadOnlyField<AssetID>("Material", MAT_NAME,
Handle<SHMaterialInstance> const& mat = component->GetMaterial(); [component]()
if(!mat) {
return static_cast<AssetID>(0); Handle<SHMaterialInstance> const& mat = component->GetMaterial();
return SHResourceManager::GetAssetID<SHMaterial>(mat->GetBaseMaterial()).value_or(0); if (!mat)
}, return static_cast<AssetID>(0);
return SHResourceManager::GetAssetID<SHMaterial>(mat->GetBaseMaterial()).value_or(0);
},
[component](AssetID const& id) [component](AssetID const& id)
{ {
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>(); auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();