I believe I managed to achieve what you asked, if I understood correctly.
Instead of closing the screen, I just hid every pane/component of it.
Keep in mind I did this with modified XMLs from my UI mod, so it should be a bit different for the default UI.
- As usual, check that the script begins with gui_ in its name:
- Also make sure that the involved xmls have scriptloadable=“true” in the Scene parameters
- Targeting is handled by TWO xmls, not just one. One for objects (target_object.xml) and one for enemies (target_enemy.xml), so both have to be called to make sure it always works.
Here’s how I impletemented it in a heartbeat script for a quick test module I made to make it work with the UI from my mod. It toggles the target UI off and on every 6 seconds, automatically. It was done this way just to show how it works in principle.
As I said before, some commands would be different for the standard UI because the panes/objects are named differently than the ones I used.
void ToggleTargetUI(object oPC, int nSTATE, int nFEEDBACK = FALSE)
int nHIDE = TRUE;
string sTXT = "Closing Target UI";
if (nSTATE == TRUE)
nHIDE = FALSE;
sTXT = "Showing Target UI";
SetGUIObjectHidden(oPC, "SCREEN_TARGETED_OBJECT", "TARGETSTYLE_new", nHIDE);
SetGUIObjectHidden(oPC, "SCREEN_TARGETED_OBJECT", "portrait", nHIDE);
SetGUIObjectHidden(oPC, "SCREEN_TARGETED_ENEMY", "TARGETSTYLE_new", nHIDE);
SetGUIObjectHidden(oPC, "SCREEN_TARGETED_ENEMY", "portrait", nHIDE);
if (nFEEDBACK == TRUE) FloatingTextStringOnCreature(sTXT, oPC, FALSE);
object oPC = GetFirstPC();
int nSTATE = GetLocalInt(oPC, "TARGET_UI_STATE");
ToggleTargetUI(oPC, nSTATE, TRUE);
if (nSTATE == TRUE) DeleteLocalInt(oPC, "TARGET_UI_STATE");
else SetLocalInt(oPC, "TARGET_UI_STATE", TRUE);
You can see its results in this video: