Remove FusionHub editor assets and update workspace

Delete unused FusionHub editor images and their .meta files, remove several shaders and test prefabs from Assets, and update .idea/.idea.HALLUCINATE/.idea/workspace.xml (cleanup changelist entries and adjust a workItem duration). Also apply modifications to Assets/Scove/UIScaleTest.unity and Assets/Scripts/UI/UIManager.cs. This cleans up editor-only/unused resources and updates the project workspace to reflect those removals.
This commit is contained in:
2026-04-25 19:24:41 +07:00
parent 034b9599f3
commit 32c598da8b
57 changed files with 89 additions and 6732 deletions

View File

@@ -12,9 +12,9 @@ namespace UI
[System.Serializable]
public class ScreenData
{
public string screenName;
public string screenName; // Phải khớp với chuỗi gọi trong ShowScreen
public UIDocument document;
public bool isActive; // Thêm lại để tương thích với Editor gốc
public bool isActive;
public bool isOverlay;
public Texture2D customCursor;
}
@@ -23,96 +23,80 @@ namespace UI
[Header("Default Settings")]
public Texture2D defaultCursor;
public string initialScreen = "MainMenu";
private VisualElement _currentScreenRoot;
private string _currentScreenName;
private void Awake()
{
Instance = this;
SyncScreens(); // Đồng bộ trạng thái ban đầu
if (Instance == null) Instance = this;
else Destroy(gameObject);
// Khởi tạo trạng thái ban đầu: Ẩn tất cả trừ màn hình mặc định
foreach (var screen in screens)
{
if (screen.document != null && screen.screenName == "Settings")
screen.document.sortingOrder = 999;
if (screen.document == null) continue;
if (screen.screenName == "Settings") screen.document.sortingOrder = 999;
screen.isActive = (screen.screenName == initialScreen);
screen.document.rootVisualElement.style.display = screen.isActive ? DisplayStyle.Flex : DisplayStyle.None;
}
}
private void Start()
{
if (!Application.isPlaying) return;
ShowScreen("MainMenu");
}
private void OnValidate()
{
// Chạy trong Editor để cập nhật UI ngay lập tức khi check vào ô isActive
if (!Application.isPlaying) SyncScreens();
_currentScreenName = initialScreen;
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
ToggleSettings();
}
if (Input.GetKeyDown(KeyCode.Escape)) ToggleSettings();
}
public void SyncScreens()
{
foreach (var screen in screens)
{
if (screen != null && screen.document != null && screen.document.rootVisualElement != null)
{
screen.document.rootVisualElement.style.display = screen.isActive ? DisplayStyle.Flex : DisplayStyle.None;
}
}
}
public void ShowOnly(string name)
{
ShowScreen(name);
}
public void ShowOnly(string name) => ShowScreen(name);
public void ShowScreen(string name)
{
if (_currentScreenName == name) return;
StartCoroutine(TransitionRoutine(name));
// Kiểm tra xem màn hình mục tiêu có tồn tại không trước khi tắt cái cũ
var nextData = screens.Find(s => s.screenName == name);
if (nextData == null)
{
Debug.LogError($"[UIManager] Screen '{name}' not found in the list! Check your Inspector names.");
return;
}
StartCoroutine(TransitionRoutine(nextData));
}
private IEnumerator TransitionRoutine(string nextScreenName)
private IEnumerator TransitionRoutine(ScreenData nextData)
{
// Tắt các màn hình khác
// 1. Fade Out các màn hình chính hiện tại (trừ Overlay)
foreach (var s in screens)
{
if (s.screenName != nextScreenName && !s.isOverlay && s.isActive)
if (s.isActive && !s.isOverlay)
{
var root = s.document.rootVisualElement.Q<VisualElement>();
root.AddToClassList("hidden");
if (root != null) root.AddToClassList("hidden");
s.isActive = false;
}
}
yield return new WaitForSeconds(0.3f);
SyncScreens();
SyncScreens(); // Ẩn hẳn display
// Bật màn hình mới
var nextData = screens.Find(s => s.screenName == nextScreenName);
if (nextData != null && nextData.document != null)
// 2. Hiện màn hình mới
nextData.isActive = true;
_currentScreenName = nextData.screenName;
var nextRoot = nextData.document.rootVisualElement.Q<VisualElement>();
if (nextRoot != null)
{
nextData.isActive = true;
_currentScreenRoot = nextData.document.rootVisualElement.Q<VisualElement>();
_currentScreenName = nextScreenName;
_currentScreenRoot.style.display = DisplayStyle.Flex;
_currentScreenRoot.AddToClassList("hidden");
yield return null;
_currentScreenRoot.RemoveFromClassList("hidden");
ApplyCursor(nextData.customCursor != null ? nextData.customCursor : defaultCursor);
nextData.document.rootVisualElement.style.display = DisplayStyle.Flex;
nextRoot.AddToClassList("hidden");
yield return null; // Chờ 1 frame để UI Toolkit cập nhật
nextRoot.RemoveFromClassList("hidden");
}
ApplyCursor(nextData.customCursor != null ? nextData.customCursor : defaultCursor);
}
public void ToggleSettings()
@@ -131,8 +115,27 @@ namespace UI
}
else
{
UnityEngine.Cursor.visible = false;
UnityEngine.Cursor.lockState = CursorLockMode.Locked;
// Nếu tắt Settings, quay về trạng thái của màn hình hiện tại
var current = screens.Find(s => s.screenName == _currentScreenName);
if (current != null) ApplyCursor(current.customCursor != null ? current.customCursor : defaultCursor);
// Tùy vào game là FPS hay Menu mà ẩn chuột
if (_currentScreenName == "HUD")
{
UnityEngine.Cursor.visible = false;
UnityEngine.Cursor.lockState = CursorLockMode.Locked;
}
}
}
public void SyncScreens()
{
foreach (var screen in screens)
{
if (screen.document != null && screen.document.rootVisualElement != null)
{
screen.document.rootVisualElement.style.display = screen.isActive ? DisplayStyle.Flex : DisplayStyle.None;
}
}
}