From 24dcd77f3273e4a565e6555f2fe44af6cb9579c6 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Sat, 12 Nov 2022 12:17:11 +0800 Subject: [PATCH] Added tooltip and range attribute support for lists in scripts --- Assets/Scripts/RaccoonShowcase.cs | 2 ++ SHADE_Engine/src/Editor/SHEditorUI.cpp | 7 +++++-- SHADE_Engine/src/Editor/SHEditorUI.h | 3 ++- SHADE_Managed/src/Editor/Editor.cxx | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/RaccoonShowcase.cs b/Assets/Scripts/RaccoonShowcase.cs index 75061b82..dc9d914d 100644 --- a/Assets/Scripts/RaccoonShowcase.cs +++ b/Assets/Scripts/RaccoonShowcase.cs @@ -18,7 +18,9 @@ public class RaccoonShowcase : Script private double rotation = 0.0; private Vector3 scale = Vector3.Zero; private double originalScale = 1.0f; + [Tooltip("Sample list of Vector3s.")] public List vecList = new List(new Vector3[] { new Vector3(1, 2, 3), new Vector3(4, 5, 6) }); + [Range(-5, 5)] public List intList = new List(new int[] { 2, 8, 2, 6, 8, 0, 1 }); public List enumList = new List(new Light.Type[] { Light.Type.Point, Light.Type.Directional, Light.Type.Ambient }); public RaccoonShowcase(GameObject gameObj) : base(gameObj) {} diff --git a/SHADE_Engine/src/Editor/SHEditorUI.cpp b/SHADE_Engine/src/Editor/SHEditorUI.cpp index 06c3f5c5..40e08042 100644 --- a/SHADE_Engine/src/Editor/SHEditorUI.cpp +++ b/SHADE_Engine/src/Editor/SHEditorUI.cpp @@ -53,9 +53,12 @@ namespace SHADE /*-----------------------------------------------------------------------------------*/ /* ImGui Wrapper Functions - Organizers */ /*-----------------------------------------------------------------------------------*/ - bool SHEditorUI::CollapsingHeader(const std::string& title) + bool SHEditorUI::CollapsingHeader(const std::string& title, bool* isHovered) { - return ImGui::CollapsingHeader(title.c_str(), ImGuiTreeNodeFlags_DefaultOpen); + const bool OPENED = ImGui::CollapsingHeader(title.c_str(), ImGuiTreeNodeFlags_DefaultOpen); + if (isHovered) + *isHovered = ImGui::IsItemHovered(); + return OPENED; } void SHEditorUI::SameLine() diff --git a/SHADE_Engine/src/Editor/SHEditorUI.h b/SHADE_Engine/src/Editor/SHEditorUI.h index 4f11a025..f450ac0d 100644 --- a/SHADE_Engine/src/Editor/SHEditorUI.h +++ b/SHADE_Engine/src/Editor/SHEditorUI.h @@ -85,8 +85,9 @@ namespace SHADE /// Wraps up ImGui::CollapsingHeader(). /// /// Label for the header. + ///