2026-10-16 20:08:13 +07:00
|
|
|
-- ==============================================================================
|
2026-10-17 01:05:58 +07:00
|
|
|
-- Hide UI Lua Script for Honkai: Star Rail
|
2026-10-16 20:08:13 +07:00
|
|
|
-- Press "ฃ" (Backslash '\' on keyboard) to toggle UI visibility
|
2026-10-17 01:05:58 +07:00
|
|
|
-- Completely hides 100% of UI elements (HUD, Minimap, UID, Texts, Battle UI, WorldUI)
|
|
|
|
|
-- Matches the clean visual result of 3Dmigoto/SRMI shader-override mod!
|
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
|
2026-10-17 01:05:58 +07:00
|
|
|
local Canvas = CS.UnityEngine.Canvas
|
2026-10-16 20:08:13 +07:00
|
|
|
local Camera = CS.UnityEngine.Camera
|
|
|
|
|
|
|
|
|
|
_G.__HIDE_UI_ENABLED = _G.__HIDE_UI_ENABLED or false
|
|
|
|
|
_G.__HIDE_UI_LAST_FRAME = _G.__HIDE_UI_LAST_FRAME or 0
|
2026-10-17 01:05:58 +07:00
|
|
|
_G.__ORIG_CAM_MASKS = _G.__ORIG_CAM_MASKS or {}
|
|
|
|
|
_G.__HIDE_UI_PERIODIC = _G.__HIDE_UI_PERIODIC or 0
|
2026-10-16 20:08:13 +07:00
|
|
|
|
2026-10-17 01:05:58 +07:00
|
|
|
local function set_canvas_group_state(obj, visible)
|
2026-10-16 20:08:13 +07:00
|
|
|
if not obj then return end
|
|
|
|
|
pcall(function()
|
|
|
|
|
local cg = obj:GetComponent(typeof(CanvasGroup))
|
|
|
|
|
if not cg then
|
|
|
|
|
cg = obj:AddComponent(typeof(CanvasGroup))
|
|
|
|
|
end
|
|
|
|
|
if cg then
|
|
|
|
|
cg.alpha = visible and 1.0 or 0.0
|
2026-10-17 01:05:58 +07:00
|
|
|
cg.blocksRaycasts = visible
|
|
|
|
|
cg.interactable = visible
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2026-10-17 01:05:58 +07:00
|
|
|
local function apply_camera_culling(visible)
|
2026-10-16 20:08:13 +07:00
|
|
|
pcall(function()
|
2026-10-17 01:05:58 +07:00
|
|
|
local allCams = Camera.allCameras
|
|
|
|
|
if allCams and allCams.Length > 0 then
|
|
|
|
|
for i = 0, allCams.Length - 1 do
|
|
|
|
|
local c = allCams[i]
|
|
|
|
|
if c and c.name then
|
|
|
|
|
local lower = string.lower(c.name)
|
|
|
|
|
-- Target UICamera and UI overlay cameras, never touch Main Camera
|
|
|
|
|
if (string.find(lower, "ui") ~= nil) and (string.find(lower, "main") == nil) then
|
|
|
|
|
local camId = c:GetInstanceID()
|
|
|
|
|
if not visible then
|
|
|
|
|
if not _G.__ORIG_CAM_MASKS[camId] and c.cullingMask ~= 0 then
|
|
|
|
|
_G.__ORIG_CAM_MASKS[camId] = c.cullingMask
|
|
|
|
|
end
|
|
|
|
|
c.cullingMask = 0
|
|
|
|
|
else
|
|
|
|
|
if _G.__ORIG_CAM_MASKS[camId] ~= nil and _G.__ORIG_CAM_MASKS[camId] ~= 0 then
|
|
|
|
|
c.cullingMask = _G.__ORIG_CAM_MASKS[camId]
|
|
|
|
|
else
|
|
|
|
|
c.cullingMask = 32 -- Default layer 5 (UI)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function apply_ui_root(visible)
|
|
|
|
|
pcall(function()
|
|
|
|
|
local uiRoot = GameObject.Find("/UIRoot") or GameObject.Find("UIRoot")
|
|
|
|
|
if uiRoot then
|
|
|
|
|
set_canvas_group_state(uiRoot, visible)
|
|
|
|
|
local tr = uiRoot.transform
|
|
|
|
|
for i = 0, tr.childCount - 1 do
|
|
|
|
|
local child = tr:GetChild(i).gameObject
|
|
|
|
|
set_canvas_group_state(child, visible)
|
|
|
|
|
local ctr = child.transform
|
|
|
|
|
for j = 0, ctr.childCount - 1 do
|
|
|
|
|
set_canvas_group_state(ctr:GetChild(j).gameObject, visible)
|
|
|
|
|
end
|
|
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
2026-10-17 01:05:58 +07:00
|
|
|
end)
|
|
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
|
2026-10-17 01:05:58 +07:00
|
|
|
local function apply_all_canvases(visible)
|
|
|
|
|
pcall(function()
|
|
|
|
|
local canvases = GameObject.FindObjectsOfType(typeof(Canvas))
|
|
|
|
|
if canvases and canvases.Length > 0 then
|
|
|
|
|
for i = 0, canvases.Length - 1 do
|
|
|
|
|
local cv = canvases[i]
|
|
|
|
|
if cv and cv.gameObject then
|
|
|
|
|
set_canvas_group_state(cv.gameObject, visible)
|
|
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function set_ui_visible(visible)
|
|
|
|
|
pcall(function()
|
2026-10-17 01:05:58 +07:00
|
|
|
-- 1. UI Camera Culling Mask
|
|
|
|
|
apply_camera_culling(visible)
|
|
|
|
|
|
|
|
|
|
-- 2. Entire /UIRoot tree (Page, HUD, Dialog, AboveDialog, Top, Popup, Guide, etc.)
|
|
|
|
|
apply_ui_root(visible)
|
|
|
|
|
|
|
|
|
|
-- 3. Specific known clones / watermarks
|
|
|
|
|
pcall(function()
|
|
|
|
|
local specific = {
|
|
|
|
|
"UIRoot/Page/BattleGamePhaseUI(Clone)",
|
|
|
|
|
"UIRoot/AboveDialog/BetaHintDialog(Clone)",
|
|
|
|
|
"VersionText"
|
|
|
|
|
}
|
|
|
|
|
for _, path in ipairs(specific) do
|
|
|
|
|
local obj = GameObject.Find(path)
|
|
|
|
|
if obj then
|
|
|
|
|
set_canvas_group_state(obj, visible)
|
|
|
|
|
end
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
2026-10-17 01:05:58 +07:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
-- 4. All active Canvases in scene (ScreenSpace & WorldSpace billboards/nameplates)
|
|
|
|
|
apply_all_canvases(visible)
|
2026-10-16 20:08:13 +07:00
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function _G.__HIDE_UI_TICK()
|
|
|
|
|
pcall(function()
|
|
|
|
|
local curFrame = Time.frameCount
|
|
|
|
|
if _G.__HIDE_UI_LAST_FRAME == curFrame then
|
|
|
|
|
return
|
|
|
|
|
end
|
2026-10-17 01:05:58 +07:00
|
|
|
_G.__HIDE_UI_LAST_FRAME = curFrame
|
2026-10-16 20:08:13 +07:00
|
|
|
|
2026-10-17 01:05:58 +07:00
|
|
|
-- Physical key '\' / 'ฃ' (KeyCode.Backslash)
|
2026-10-16 20:08:13 +07:00
|
|
|
if Input.GetKeyDown(KeyCode.Backslash) then
|
|
|
|
|
_G.__HIDE_UI_ENABLED = not _G.__HIDE_UI_ENABLED
|
|
|
|
|
|
|
|
|
|
set_ui_visible(not _G.__HIDE_UI_ENABLED)
|
|
|
|
|
|
|
|
|
|
if _G.__HIDE_UI_ENABLED then
|
2026-10-17 01:05:58 +07:00
|
|
|
CS.UnityEngine.Debug.Log("<color=#FF00FF>[UI Toggle]</color> <color=#FF5555>UI Hidden (ซ่อน UI ทั้งหมด 100% เรียบร้อย)</color>")
|
2026-10-16 20:08:13 +07:00
|
|
|
else
|
2026-10-17 01:05:58 +07:00
|
|
|
CS.UnityEngine.Debug.Log("<color=#FF00FF>[UI Toggle]</color> <color=#55FF55>UI Restored (แสดง UI ตามปกติแล้ว)</color>")
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2026-10-17 01:05:58 +07:00
|
|
|
-- While hidden, keep enforcing to prevent newly spawned UI from appearing
|
2026-10-16 20:08:13 +07:00
|
|
|
if _G.__HIDE_UI_ENABLED then
|
2026-10-17 01:05:58 +07:00
|
|
|
apply_camera_culling(false)
|
|
|
|
|
apply_ui_root(false)
|
|
|
|
|
|
|
|
|
|
_G.__HIDE_UI_PERIODIC = (_G.__HIDE_UI_PERIODIC or 0) + 1
|
|
|
|
|
if _G.__HIDE_UI_PERIODIC >= 30 then
|
|
|
|
|
_G.__HIDE_UI_PERIODIC = 0
|
|
|
|
|
apply_all_canvases(false)
|
|
|
|
|
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 01:05:58 +07:00
|
|
|
CS.UnityEngine.Debug.Log("<color=#FF00FF>[UI Toggle Script]</color> 100% Clean HideUI loaded! Press 'ฃ' to toggle UI.")
|
2026-10-16 20:08:13 +07:00
|
|
|
end
|