Pre-load button textures #360
|
@ -28,16 +28,19 @@ namespace SHADE
|
|||
void SHButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
||||
{
|
||||
defaultTexture = texture;
|
||||
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||
}
|
||||
|
||||
void SHButtonComponent::SetHoveredTexture(AssetID texture) noexcept
|
||||
{
|
||||
hoveredTexture = texture;
|
||||
SHResourceManager::LoadOrGet<SHTexture>(texture);\
|
||||
}
|
||||
|
||||
void SHButtonComponent::SetClickedTexture(AssetID texture) noexcept
|
||||
{
|
||||
clickedTexture = texture;
|
||||
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHToggleButtonComponent.h"
|
||||
|
||||
#include "Resource/SHResourceManager.h"
|
||||
#include "Graphics/MiddleEnd/Textures/SHTextureLibrary.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -28,11 +29,13 @@ namespace SHADE
|
|||
void SHToggleButtonComponent::SetDefaultTexture(AssetID texture) noexcept
|
||||
{
|
||||
defaultTexture = texture;
|
||||
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||
}
|
||||
|
||||
void SHToggleButtonComponent::SetToggledTexture(AssetID texture) noexcept
|
||||
{
|
||||
toggledTexture = texture;
|
||||
SHResourceManager::LoadOrGet<SHTexture>(texture);
|
||||
}
|
||||
|
||||
void SHToggleButtonComponent::SetValue(bool value) noexcept
|
||||
|
|
|
@ -313,8 +313,8 @@ namespace SHADE
|
|||
{
|
||||
auto material = renderable->GetModifiableMaterial();
|
||||
comp.currentTexture = textureID;
|
||||
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
|
||||
loadTexture = true;
|
||||
material->SetProperty("data.textureIndex", SHResourceManager::Get<SHTexture>(textureID)->TextureArrayIndex);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -368,8 +368,8 @@ namespace SHADE
|
|||
{
|
||||
auto material = renderable->GetModifiableMaterial();
|
||||
comp.currentTexture = textureID;
|
||||
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
|
||||
loadTexture = true;
|
||||
material->SetProperty("data.textureIndex", SHResourceManager::Get<SHTexture>(textureID)->TextureArrayIndex);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -381,6 +381,8 @@ namespace SHADE
|
|||
{
|
||||
SHUISystem* system = (SHUISystem*)GetSystem();
|
||||
auto& dense = SHComponentManager::GetDense<SHButtonComponent>();
|
||||
//We ensure that the textures are loaded before we do the update.
|
||||
SHResourceManager::FinaliseChanges();
|
||||
for (auto& comp : dense)
|
||||
{
|
||||
if (SHSceneManager::CheckNodeAndComponentsActive<SHButtonComponent>(comp.GetEID()))
|
||||
|
@ -393,11 +395,6 @@ namespace SHADE
|
|||
if (SHSceneManager::CheckNodeAndComponentsActive<SHToggleButtonComponent>(comp.GetEID()))
|
||||
system->UpdateToggleButtonComponent(comp);
|
||||
}
|
||||
if (system->loadTexture == true)
|
||||
{
|
||||
system->loadTexture = false;
|
||||
SHResourceManager::FinaliseChanges();
|
||||
}
|
||||
}
|
||||
|
||||
SHVec2 SHUISystem::CanvasToScreenPoint(SHVec2& const canvasPoint, bool normalized) noexcept
|
||||
|
|
Loading…
Reference in New Issue