Upd
This commit is contained in:
@@ -36,6 +36,9 @@ namespace UI
|
||||
private Stack<string> _navigationStack = new Stack<string>();
|
||||
private string _currentScreenName;
|
||||
private VisualElement _lastHoveredElement;
|
||||
|
||||
// Flags for MainMenu state
|
||||
public bool isMainMenuActive = false;
|
||||
private bool _isSettingsOpen = false;
|
||||
|
||||
private void Awake()
|
||||
@@ -60,8 +63,7 @@ namespace UI
|
||||
var root = doc.rootVisualElement;
|
||||
|
||||
_customCursor = new VisualElement();
|
||||
_customCursor.style.width = 25;
|
||||
_customCursor.style.height = 25;
|
||||
_customCursor.style.width = 25; _customCursor.style.height = 25;
|
||||
_customCursor.style.backgroundColor = Color.white;
|
||||
_customCursor.style.borderTopLeftRadius = 13; _customCursor.style.borderTopRightRadius = 13;
|
||||
_customCursor.style.borderBottomLeftRadius = 13; _customCursor.style.borderBottomRightRadius = 13;
|
||||
@@ -86,15 +88,15 @@ namespace UI
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Calculate Virtual Mouse Position
|
||||
Vector2 mousePos = Input.mousePosition;
|
||||
|
||||
bool isMainMenu = (_currentScreenName == "MainMenu");
|
||||
bool restrictY = (isMainMenu && !_isSettingsOpen);
|
||||
bool restrictY = (isMainMenu && isMainMenuActive && !_isSettingsOpen);
|
||||
|
||||
float targetY = restrictY ? Screen.height / 2f : mousePos.y;
|
||||
Vector2 uiPos = new Vector2(mousePos.x, Screen.height - targetY);
|
||||
|
||||
// Visibility Logic for Cursor & Trail
|
||||
bool showCursor = !isMainMenu || _isSettingsOpen;
|
||||
bool showCursor = !isMainMenu || !isMainMenuActive || _isSettingsOpen;
|
||||
DisplayStyle cursorDisplay = showCursor ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
|
||||
if (_customCursor != null)
|
||||
@@ -110,17 +112,14 @@ namespace UI
|
||||
currentTrail.style.left = uiPos.x - 9;
|
||||
currentTrail.style.top = uiPos.y - 9;
|
||||
currentTrail.style.opacity = 0.5f;
|
||||
|
||||
foreach(var t in _trailPool)
|
||||
{
|
||||
t.style.display = cursorDisplay;
|
||||
t.style.opacity = Mathf.Max(0, t.style.opacity.value - Time.deltaTime * 4f);
|
||||
}
|
||||
|
||||
_trailIndex = (_trailIndex + 1) % _trailPool.Count;
|
||||
}
|
||||
|
||||
// Handle Focus & Clicks using virtual coordinates
|
||||
HandleVirtualInput(uiPos);
|
||||
|
||||
if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.O))
|
||||
@@ -168,7 +167,7 @@ namespace UI
|
||||
}
|
||||
}
|
||||
|
||||
// --- Editor Support Methods ---
|
||||
// --- Editor Support Methods (Restored) ---
|
||||
|
||||
public void SyncScreens()
|
||||
{
|
||||
@@ -201,7 +200,7 @@ namespace UI
|
||||
|
||||
if (!screen.isOverlay)
|
||||
{
|
||||
foreach(var s in screens) if(!s.isOverlay) s.document.rootVisualElement.style.display = DisplayStyle.None;
|
||||
foreach(var s in screens) if(!s.isOverlay && s.document != null) s.document.rootVisualElement.style.display = DisplayStyle.None;
|
||||
_navigationStack.Push(name);
|
||||
_currentScreenName = name;
|
||||
}
|
||||
@@ -219,8 +218,12 @@ namespace UI
|
||||
if (currentData != null) currentData.document.rootVisualElement.style.display = DisplayStyle.None;
|
||||
|
||||
_currentScreenName = _navigationStack.Peek();
|
||||
var prev = screens.Find(s => s.screenName == _currentScreenName);
|
||||
if (prev != null) prev.document.rootVisualElement.style.display = DisplayStyle.Flex;
|
||||
var prevData = screens.Find(s => s.screenName == _currentScreenName);
|
||||
if (prevData != null)
|
||||
{
|
||||
prevData.document.rootVisualElement.style.display = DisplayStyle.Flex;
|
||||
prevData.isActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleSettings()
|
||||
@@ -230,6 +233,8 @@ namespace UI
|
||||
_isSettingsOpen = settings.document.rootVisualElement.style.display == DisplayStyle.None;
|
||||
settings.document.rootVisualElement.style.display = _isSettingsOpen ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
settings.isActive = _isSettingsOpen;
|
||||
|
||||
if (_isSettingsOpen) settings.document.sortingOrder = 999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user