diff --git a/SHADE_Managed/src/Editor/Editor.cxx b/SHADE_Managed/src/Editor/Editor.cxx index db49201b..629c9e65 100644 --- a/SHADE_Managed/src/Editor/Editor.cxx +++ b/SHADE_Managed/src/Editor/Editor.cxx @@ -142,15 +142,7 @@ namespace SHADE SHEditorUI::Indent(); { // Right Click Menu - if (SHEditorUI::BeginPopupContextItem("scriptContextMenu")) - { - if (SHEditorUI::Selectable("Delete Script", ICON_MD_DELETE)) - { - // Mark script for removal - ScriptStore::RemoveScript(entity, script); - } - SHEditorUI::EndPopup(); - } + renderScriptContextMenu(entity, script); // Go through all fields and output them auto fields = ReflectionUtilities::GetInstanceFields(script); @@ -171,6 +163,10 @@ namespace SHADE SHEditorUI::Unindent(); SHEditorUI::PopID(); } + else + { + renderScriptContextMenu(entity, script); + } SHEditorUI::PopID(); } void Editor::renderFieldInInspector(Reflection::FieldInfo^ field, Object^ object) @@ -220,4 +216,19 @@ namespace SHADE } } } + + void Editor::renderScriptContextMenu(Entity entity, Script^ script) + { + // Right Click Menu + if (SHEditorUI::BeginPopupContextItem("scriptContextMenu")) + { + if (SHEditorUI::Selectable("Delete Script", ICON_MD_DELETE)) + { + // Mark script for removal + ScriptStore::RemoveScript(entity, script); + } + SHEditorUI::EndPopup(); + } + } + } diff --git a/SHADE_Managed/src/Editor/Editor.hxx b/SHADE_Managed/src/Editor/Editor.hxx index a38cbf79..188da660 100644 --- a/SHADE_Managed/src/Editor/Editor.hxx +++ b/SHADE_Managed/src/Editor/Editor.hxx @@ -67,5 +67,11 @@ namespace SHADE /// The object that contains the data of the field to render. /// static void renderFieldInInspector(System::Reflection::FieldInfo^ field, Object^ object); + /// + /// Renders a context menu when right clicked for the scripts + /// + /// The Entity to render the Scripts of. + /// The Script to render the inspector for. + static void renderScriptContextMenu(Entity entity, Script^ script); }; }