This commit is contained in:
2026-04-28 10:11:28 +07:00
parent 252489f48a
commit 6d5a9a4e5b
8 changed files with 137 additions and 742 deletions

View File

@@ -3,6 +3,9 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UIElements;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Hallucinate.UI
{
@@ -17,6 +20,9 @@ namespace Hallucinate.UI
private readonly Dictionary<Type, BaseUIController> _controllers = new Dictionary<Type, BaseUIController>();
private readonly Stack<BaseUIController> _history = new Stack<BaseUIController>();
[Header("Game Metadata")]
[SerializeField] private Texture2D gameIcon;
[Header("UI Templates")]
[SerializeField] private VisualTreeAsset mainMenuTemplate;
[SerializeField] private VisualTreeAsset lobbyTemplate;
@@ -48,6 +54,14 @@ namespace Hallucinate.UI
_uiDocument = GetComponent<UIDocument>();
_rootElement = _uiDocument.rootVisualElement;
#if UNITY_EDITOR
if (gameIcon == null)
{
var icons = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown);
if (icons != null && icons.Length > 0) gameIcon = icons[0];
}
#endif
InitializeControllers();
}
@@ -55,6 +69,11 @@ namespace Hallucinate.UI
private void InitializeControllers()
{
_mainMenuController = RegisterController<MainMenuController>(mainMenuTemplate);
if (_mainMenuController != null && gameIcon != null)
{
_mainMenuController.SetGameIcon(gameIcon);
}
_lobbyController = RegisterController<LobbyController>(lobbyTemplate);
_profileController = RegisterController<ProfileController>(profileTemplate);
_settingsController = RegisterController<SettingsController>(settingsTemplate);
@@ -120,7 +139,5 @@ namespace Hallucinate.UI
var previousScreen = _history.Peek();
await previousScreen.PlayTransitionIn();
}
// Custom Inspector features can be added here with [ContextMenu] or CustomEditor
}
}