diff --git a/SHADE_Engine/src/UI/SHUISystem.cpp b/SHADE_Engine/src/UI/SHUISystem.cpp index c75af66f..f8fa1c43 100644 --- a/SHADE_Engine/src/UI/SHUISystem.cpp +++ b/SHADE_Engine/src/UI/SHUISystem.cpp @@ -28,6 +28,8 @@ namespace SHADE SHComponentManager::CreateComponentSparseSet(); SHComponentManager::CreateComponentSparseSet(); SHComponentManager::CreateComponentSparseSet(); + SHComponentManager::CreateComponentSparseSet(); + SHComponentManager::CreateComponentSparseSet(); } void SHUISystem::Exit() @@ -272,6 +274,7 @@ namespace SHADE } auto cameraSystem = SHSystemManager::GetSystem(); auto uiComp = SHComponentManager::GetComponent(comp.GetEID()); + //auto canvasComp = SHComponentManager::GetComponent_s(uiComp->canvasID); SHVec4 topExtent4 = SHMatrix::Translate(-comp.size.x * 0.5f, comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f); SHVec4 btmExtent4 = SHMatrix::Translate(comp.size.x * 0.5f, -comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f); @@ -280,15 +283,15 @@ namespace SHADE SHVec2 topExtent{ topExtent4.x,topExtent4.y }; SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y }; + SHVec2 mousePos; SHVec2 windowSize; - #ifdef SHEDITOR windowSize = SHEditorWindowManager::GetEditorWindow()->beginContentRegionAvailable; mousePos = SHEditorWindowManager::GetEditorWindow()->viewportMousePos; //mousePos.y = windowSize.y - mousePos.y; //SHLOG_INFO("mouse pos: {}, {}", mousePos.x, mousePos.y) - mousePos /= windowSize; + mousePos /= windowSize; //SHLOG_INFO("mouse pos normalized: {}, {}", mousePos.x, mousePos.y) @@ -305,21 +308,20 @@ namespace SHADE #endif SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0) }; + //SHLOG_INFO("TopExtent: {}, {}", topExtent.x, topExtent.y) - - - topExtent = CanvasToScreenPoint(topExtent,true); + topExtent = CanvasToScreenPoint(topExtent, true); btmExtent = CanvasToScreenPoint(btmExtent, true); + //SHLOG_INFO("TopExtent: {}, {} Btm Extent: {}, {}", topExtent.x, topExtent.y, btmExtent.x, btmExtent.y) - - comp.isClicked = false; + //comp.isClicked = false; if (mousePos.x >= topExtent.x && mousePos.x <= btmExtent.x && mousePos.y >= topExtent.y && mousePos.y <= btmExtent.y) { comp.isHovered = true; #ifdef SHEDITOR - if (SHSystemManager::GetSystem()->editorState == SHEditor::State::PLAY) + //if (SHSystemManager::GetSystem()->editorState == SHEditor::State::PLAY) { if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB)) { @@ -330,22 +332,22 @@ namespace SHADE if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LMB)) { comp.isClicked = true; - } + } #endif - } + + //SHLOG_INFO("HOVERED") + } else { comp.isHovered = false; + //SHLOG_INFO("NOT HOVERED") } - - if (comp.isClicked && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB)) { comp.isClicked = false; comp.value = !comp.value; SHButtonClickEvent clickEvent; clickEvent.EID = comp.GetEID(); - clickEvent.value = comp.value; SHEventManager::BroadcastEvent(clickEvent, SH_BUTTON_CLICK_EVENT); }