From a181d7b8960cbb637af5f3336dd59bbfa7634c48 Mon Sep 17 00:00:00 2001 From: maverickdgg Date: Fri, 18 Nov 2022 16:37:33 +0800 Subject: [PATCH] Added Canvas and UI to editor --- .../EditorWindow/Inspector/SHEditorInspector.cpp | 11 +++++++++++ SHADE_Engine/src/UI/SHUIComponent.cpp | 13 ++++++++++++- SHADE_Engine/src/UI/SHUIComponent.h | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp index f240e321..3a5a15b5 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp @@ -18,6 +18,8 @@ #include "Physics/Interface/SHColliderComponent.h" #include "Camera/SHCameraComponent.h" #include "Camera/SHCameraArmComponent.h" +#include "UI/SHUIComponent.h" +#include "UI/SHCanvasComponent.h" #include "SHEditorComponentView.h" namespace SHADE @@ -132,6 +134,14 @@ namespace SHADE { DrawComponent(cameraArmComponent); } + if (auto canvasComponent= SHComponentManager::GetComponent_s(eid)) + { + DrawComponent(canvasComponent); + } + if (auto uiComponent = SHComponentManager::GetComponent_s(eid)) + { + DrawComponent(uiComponent); + } ImGui::Separator(); // Render Scripts SHScriptEngine* scriptEngine = static_cast(SHSystemManager::GetSystem()); @@ -143,6 +153,7 @@ namespace SHADE DrawAddComponentButton(eid); DrawAddComponentButton(eid); DrawAddComponentButton(eid); + DrawAddComponentButton(eid); // Components that require Transforms diff --git a/SHADE_Engine/src/UI/SHUIComponent.cpp b/SHADE_Engine/src/UI/SHUIComponent.cpp index 23c86ec3..8131d081 100644 --- a/SHADE_Engine/src/UI/SHUIComponent.cpp +++ b/SHADE_Engine/src/UI/SHUIComponent.cpp @@ -17,6 +17,16 @@ namespace SHADE return localToCanvasMatrix; } + EntityID SHUIComponent::GetCanvasID() const noexcept + { + return canvasID; + } + + void SHUIComponent::SetCanvasID(EntityID id) noexcept + { + (void)id; + } + } @@ -25,7 +35,8 @@ RTTR_REGISTRATION using namespace SHADE; using namespace rttr; - registration::class_("Canvas Component") + registration::class_("UI Component") + .property("Canvas ID", &SHUIComponent::GetCanvasID, &SHUIComponent::SetCanvasID) ; diff --git a/SHADE_Engine/src/UI/SHUIComponent.h b/SHADE_Engine/src/UI/SHUIComponent.h index 190a40e1..5a9290cc 100644 --- a/SHADE_Engine/src/UI/SHUIComponent.h +++ b/SHADE_Engine/src/UI/SHUIComponent.h @@ -18,7 +18,8 @@ namespace SHADE ~SHUIComponent() = default; SHMatrix const& GetMatrix() const noexcept; - + EntityID GetCanvasID() const noexcept; + void SetCanvasID(EntityID id) noexcept; private: SHMatrix localToCanvasMatrix; -- 2.40.1