From 1b865b129b7ad0b9715282d0374e4892103e601d Mon Sep 17 00:00:00 2001 From: maverickdgg Date: Thu, 23 Feb 2023 12:50:42 +0800 Subject: [PATCH] Added finalizeChanges call and debug logs for hover enter --- Assets/Scripts/UI/SC_ChangeSceneButton.cs | 9 +++++---- SHADE_Engine/src/UI/SHUISystem.cpp | 8 ++++++++ SHADE_Engine/src/UI/SHUISystem.h | 2 ++ SHADE_Managed/src/Components/UIElement.cxx | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/UI/SC_ChangeSceneButton.cs b/Assets/Scripts/UI/SC_ChangeSceneButton.cs index 6caba2b1..4ce87cc8 100644 --- a/Assets/Scripts/UI/SC_ChangeSceneButton.cs +++ b/Assets/Scripts/UI/SC_ChangeSceneButton.cs @@ -11,13 +11,14 @@ public class ChangeSceneButton : Script UIElement ui = GetComponent(); if (ui != null) { - ui.OnClick.RegisterAction(() => + ui.OnHoverEnter.RegisterAction(() => { + Debug.Log("C# Hover Enter"); if (sceneID != 0) { - Audio.PlaySFXOnce2D("event:/UI/success"); - SceneManager.ChangeScene(sceneID); - Audio.StopAllSounds(); + //Audio.PlaySFXOnce2D("event:/UI/success"); + //SceneManager.ChangeScene(sceneID); + //Audio.StopAllSounds(); } }); } diff --git a/SHADE_Engine/src/UI/SHUISystem.cpp b/SHADE_Engine/src/UI/SHUISystem.cpp index 3552e47b..aeb30b0b 100644 --- a/SHADE_Engine/src/UI/SHUISystem.cpp +++ b/SHADE_Engine/src/UI/SHUISystem.cpp @@ -204,6 +204,7 @@ namespace SHADE SHButtonClickEvent clickEvent; clickEvent.EID = comp.GetEID(); SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_HOVER_ENTER_EVENT); + SHLOG_INFO("C++ BROADCASTED HOVER ENTER EVENT EID: {}", clickEvent.EID); } comp.isHovered = true; @@ -313,6 +314,7 @@ namespace SHADE auto material = renderable->GetModifiableMaterial(); comp.currentTexture = textureID; material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet(textureID)); + loadTexture = true; } @@ -367,6 +369,7 @@ namespace SHADE auto material = renderable->GetModifiableMaterial(); comp.currentTexture = textureID; material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet(textureID)); + loadTexture = true; } @@ -390,6 +393,11 @@ namespace SHADE if (SHSceneManager::CheckNodeAndComponentsActive(comp.GetEID())) system->UpdateToggleButtonComponent(comp); } + if (system->loadTexture == true) + { + system->loadTexture = false; + SHResourceManager::FinaliseChanges(); + } } SHVec2 SHUISystem::CanvasToScreenPoint(SHVec2& const canvasPoint, bool normalized) noexcept diff --git a/SHADE_Engine/src/UI/SHUISystem.h b/SHADE_Engine/src/UI/SHUISystem.h index 3b2bb2cf..f3f7847e 100644 --- a/SHADE_Engine/src/UI/SHUISystem.h +++ b/SHADE_Engine/src/UI/SHUISystem.h @@ -68,6 +68,8 @@ namespace SHADE private: + bool loadTexture{false}; + void UpdateUIComponent(SHUIComponent& comp) noexcept; void UpdateButtonComponent(SHButtonComponent& comp) noexcept; void UpdateToggleButtonComponent(SHToggleButtonComponent& comp) noexcept; diff --git a/SHADE_Managed/src/Components/UIElement.cxx b/SHADE_Managed/src/Components/UIElement.cxx index 42b8caef..75e16a1c 100644 --- a/SHADE_Managed/src/Components/UIElement.cxx +++ b/SHADE_Managed/src/Components/UIElement.cxx @@ -63,7 +63,7 @@ namespace SHADE } // Return the event - return onClickEventMap[owner.EntityId]; + return onReleasedEventMap[owner.EntityId]; } CallbackEvent^ UIElement::OnHoverEnter::get() {