fix clicked texture to take priority over hovered texture

This commit is contained in:
maverickdgg 2023-01-16 14:44:20 +08:00
parent 077f6f0fc9
commit 1e351366af
1 changed files with 11 additions and 12 deletions

View File

@ -232,7 +232,7 @@ namespace SHADE
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
{
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
if(!comp.isHovered && !comp.isClicked)
@ -241,8 +241,15 @@ namespace SHADE
material->SetProperty("data.textureIndex", comp.GetDefaultTexture());
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
if (comp.isHovered)
else if (comp.isClicked)
{
if (SHAssetManager::GetType(comp.GetClickedTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetClickedTexture());
//SHLOG_INFO("SETTING CLICKED TEXTURE")
}
}
else
{
if (SHAssetManager::GetType(comp.GetHoveredTexture()) == AssetType::TEXTURE)
{
@ -250,14 +257,6 @@ namespace SHADE
//SHLOG_INFO("SETTING HOVERED TEXTURE")
}
}
else
{
if (SHAssetManager::GetType(comp.GetClickedTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", comp.GetClickedTexture());
SHLOG_INFO("SETTING CLICKED TEXTURE")
}
}
@ -353,7 +352,7 @@ namespace SHADE
if (SHComponentManager::HasComponent<SHRenderable>(comp.GetEID()))
{
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
if (comp.GetValue() == false)