I managed to accomplish this in my own unit/raid frames by parenting the party frames to one frame and hiding that frame using a SecureHandlerStateTemplate (which also doubles as the main table for the addon).
Creation:
lua Code:
local main = CreateFrame("Frame", "DayveUF_Main", UIParent, "SecureHandlerStateTemplate");
SecureHandler_OnLoad(main);
main.partyMain = CreateFrame("Frame", nil, main);
Initialisation:
lua Code:
self:SetFrameRef("PartyMain", self.partyMain);
self:Execute([[
PartyMain = self:GetFrameRef("PartyMain");
]]);
self:SetAttribute("_onstate-unitexists", [[
if raidhideparty and newstate then
PartyMain:Hide()
else
PartyMain:Show()
end
]]);
self:SetAttribute("unit", "raid1");
RegisterUnitWatch(self, true);
And to turn the behaviour on or off to reflect the user's setting:
lua Code:
self:Execute(self.save.raidhideparty and [[
raidhideparty = true;
]] or [[
raidhideparty = false;
]]);
self:SetAttribute("state-unitexists", UnitExists("raid1"));