2026-10-17 23:44:36 +07:00
|
|
|
-- Backslash toggles HUD only. Keep pages, dialogs and UI cameras visible.
|
2026-10-16 20:08:13 +07:00
|
|
|
local Input = CS.UnityEngine.Input
|
|
|
|
|
local KeyCode = CS.UnityEngine.KeyCode
|
|
|
|
|
local Time = CS.UnityEngine.Time
|
|
|
|
|
local GameObject = CS.UnityEngine.GameObject
|
|
|
|
|
local CanvasGroup = CS.UnityEngine.CanvasGroup
|
|
|
|
|
local Camera = CS.UnityEngine.Camera
|
|
|
|
|
|
2026-10-17 23:44:36 +07:00
|
|
|
-- Names observed under UIRoot in this Client, plus the existing battle HUD.
|
|
|
|
|
-- Never target an ancestor shared by HUD and character/reward dialogs.
|
|
|
|
|
local HUD_PATHS = {
|
|
|
|
|
"UIRoot/Page/MazeMainPage(Clone)",
|
|
|
|
|
"UIRoot/Page/BattleGamePhaseUI(Clone)",
|
|
|
|
|
"UIRoot/BelowPage/AdventureWaypointsPage(Clone)",
|
|
|
|
|
"UIRoot/BelowPage/MazeJumpingText(Clone)",
|
|
|
|
|
"UIRoot/BelowPage/MazeMonsterWarningPage(Clone)",
|
|
|
|
|
"UIRoot/AboveDialog/BetaHintDialog(Clone)",
|
2026-10-17 23:49:51 +07:00
|
|
|
-- Character controls observed under AvatarMainPage/Root. Keep RankPanel
|
|
|
|
|
-- and dialogs intact so Eidolon illustrations are not hidden with menus.
|
|
|
|
|
"UIRoot/Page/AvatarMainPage(Clone)/Root/AvatarSubMenuPanel_Vertical",
|
|
|
|
|
"UIRoot/Page/AvatarMainPage(Clone)/Root/AvatarDetailPanel",
|
|
|
|
|
"UIRoot/Page/AvatarMainPage(Clone)/Root/AvatarTopListPanel",
|
|
|
|
|
"UIRoot/Page/AvatarMainPage(Clone)/Root/AvatarListPanel",
|
|
|
|
|
"UIRoot/Page/AvatarMainPage(Clone)/Root/BtnClose",
|
|
|
|
|
"UIRoot/Page/AvatarMainPage(Clone)/Root/TopBarArea",
|
2026-10-17 23:44:36 +07:00
|
|
|
"VersionText"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- The old script did not record CanvasGroup state. Undo its blanket hide once
|
|
|
|
|
-- on live upgrade; a fresh Client session avoids any lost legacy fade state.
|
|
|
|
|
if _G.__HIDE_UI_REGISTERED and _G.__HIDE_UI_SCHEMA ~= 2 and _G.__HIDE_UI_ENABLED then
|
2026-10-16 20:08:13 +07:00
|
|
|
pcall(function()
|
2026-10-17 23:44:36 +07:00
|
|
|
local cams = Camera.allCameras
|
|
|
|
|
for i = 0, cams.Length - 1 do
|
|
|
|
|
local mask = (_G.__ORIG_CAM_MASKS or {})[cams[i]:GetInstanceID()]
|
|
|
|
|
if mask ~= nil then cams[i].cullingMask = mask end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
2026-10-17 23:44:36 +07:00
|
|
|
local function restore(obj)
|
|
|
|
|
if obj then
|
|
|
|
|
local cg = obj:GetComponent(typeof(CanvasGroup))
|
|
|
|
|
if cg then cg.alpha = 1; cg.blocksRaycasts = true; cg.interactable = true end
|
2026-10-17 01:05:58 +07:00
|
|
|
end
|
|
|
|
|
end
|
2026-10-17 23:44:36 +07:00
|
|
|
local root = GameObject.Find("UIRoot")
|
|
|
|
|
if root then
|
|
|
|
|
restore(root)
|
|
|
|
|
local t = root.transform
|
|
|
|
|
for i = 0, t.childCount - 1 do
|
|
|
|
|
local c = t:GetChild(i); restore(c.gameObject)
|
|
|
|
|
for j = 0, c.childCount - 1 do restore(c:GetChild(j).gameObject) end
|
2026-10-17 01:05:58 +07:00
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
2026-10-17 23:44:36 +07:00
|
|
|
local canvases = GameObject.FindObjectsOfType(typeof(CS.UnityEngine.Canvas))
|
|
|
|
|
for i = 0, canvases.Length - 1 do restore(canvases[i].gameObject) end
|
2026-10-17 01:05:58 +07:00
|
|
|
end)
|
|
|
|
|
end
|
2026-10-17 23:44:36 +07:00
|
|
|
_G.__HIDE_UI_SCHEMA = 2
|
|
|
|
|
_G.__HIDE_UI_ENABLED = _G.__HIDE_UI_ENABLED or false
|
|
|
|
|
_G.__HIDE_UI_TARGETS = _G.__HIDE_UI_TARGETS or {}
|
2026-10-16 20:08:13 +07:00
|
|
|
|
2026-10-17 23:44:36 +07:00
|
|
|
local function restore_hud()
|
|
|
|
|
for id, state in pairs(_G.__HIDE_UI_TARGETS) do
|
|
|
|
|
pcall(function()
|
|
|
|
|
if state.group then
|
|
|
|
|
if state.added then
|
|
|
|
|
CS.UnityEngine.Object.Destroy(state.group)
|
|
|
|
|
else
|
|
|
|
|
state.group.alpha = state.alpha
|
|
|
|
|
state.group.blocksRaycasts = state.raycast
|
|
|
|
|
state.group.interactable = state.interactable
|
2026-10-17 01:05:58 +07:00
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
2026-10-17 23:44:36 +07:00
|
|
|
end)
|
|
|
|
|
_G.__HIDE_UI_TARGETS[id] = nil
|
|
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
|
|
|
|
|
2026-10-17 23:44:36 +07:00
|
|
|
local function hide_hud()
|
|
|
|
|
for _, path in ipairs(HUD_PATHS) do
|
2026-10-17 01:05:58 +07:00
|
|
|
pcall(function()
|
2026-10-17 23:44:36 +07:00
|
|
|
local obj = GameObject.Find(path)
|
|
|
|
|
if not obj then return end
|
|
|
|
|
local id = obj:GetInstanceID()
|
|
|
|
|
local state = _G.__HIDE_UI_TARGETS[id]
|
|
|
|
|
if not state then
|
|
|
|
|
local group = obj:GetComponent(typeof(CanvasGroup))
|
|
|
|
|
local added = not group
|
|
|
|
|
if added then group = obj:AddComponent(typeof(CanvasGroup)) end
|
|
|
|
|
state = {group=group, added=added, alpha=group.alpha,
|
|
|
|
|
raycast=group.blocksRaycasts, interactable=group.interactable}
|
|
|
|
|
_G.__HIDE_UI_TARGETS[id] = state
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
2026-10-17 23:44:36 +07:00
|
|
|
state.group.alpha = 0
|
|
|
|
|
state.group.blocksRaycasts = false
|
|
|
|
|
state.group.interactable = false
|
2026-10-17 01:05:58 +07:00
|
|
|
end)
|
2026-10-17 23:44:36 +07:00
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function _G.__HIDE_UI_TICK()
|
|
|
|
|
pcall(function()
|
2026-10-17 23:44:36 +07:00
|
|
|
local frame = Time.frameCount
|
|
|
|
|
if _G.__HIDE_UI_LAST_FRAME == frame then return end
|
|
|
|
|
_G.__HIDE_UI_LAST_FRAME = frame
|
|
|
|
|
local toggled = Input.GetKeyDown(KeyCode.Backslash)
|
|
|
|
|
if toggled then
|
2026-10-16 20:08:13 +07:00
|
|
|
_G.__HIDE_UI_ENABLED = not _G.__HIDE_UI_ENABLED
|
2026-10-17 23:44:36 +07:00
|
|
|
if not _G.__HIDE_UI_ENABLED then restore_hud() end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
2026-10-17 23:44:36 +07:00
|
|
|
-- Only the small named HUD list is checked, four times a second.
|
|
|
|
|
-- New pages/dialogs never inherit a hidden UIRoot or UI camera.
|
2026-10-16 20:08:13 +07:00
|
|
|
if _G.__HIDE_UI_ENABLED then
|
2026-10-17 23:44:36 +07:00
|
|
|
local now = Time.unscaledTime
|
|
|
|
|
if toggled or now >= (_G.__HIDE_UI_NEXT_SCAN or 0) then
|
|
|
|
|
_G.__HIDE_UI_NEXT_SCAN = now + 0.25
|
|
|
|
|
hide_hud()
|
2026-10-17 01:05:58 +07:00
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Hook into render pipeline
|
|
|
|
|
if not _G.__HIDE_UI_REGISTERED then
|
|
|
|
|
_G.__HIDE_UI_REGISTERED = true
|
|
|
|
|
|
|
|
|
|
local function hook(target, evt)
|
|
|
|
|
pcall(function() target[evt]('+', function(c) _G.__HIDE_UI_TICK() end) end)
|
|
|
|
|
pcall(function() target[evt] = target[evt] + function(c) _G.__HIDE_UI_TICK() end end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
hook(Camera, "onPreRender")
|
|
|
|
|
hook(Camera, "onPreCull")
|
|
|
|
|
hook(Camera, "onPostRender")
|
|
|
|
|
pcall(function() CS.UnityEngine.Application.onBeforeRender('+', function() _G.__HIDE_UI_TICK() end) end)
|
|
|
|
|
pcall(function() CS.UnityEngine.Application.onBeforeRender = CS.UnityEngine.Application.onBeforeRender + function() _G.__HIDE_UI_TICK() end end)
|
|
|
|
|
|
2026-10-17 23:44:36 +07:00
|
|
|
CS.UnityEngine.Debug.Log("<color=#FF00FF>[UI Toggle Script]</color> HUD-only HideUI loaded! Press 'ฃ' to toggle UI.")
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|